Decompiled source of UFO ImPost v2.2.1

UFO_ImPost.dll

Decompiled 14 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UFO_ImPost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UFO_ImPost")]
[assembly: AssemblyTitle("UFO_ImPost")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UFOImPost
{
	internal class CargoHauler
	{
		private static readonly Color Yellow = new Color(1f, 0.8f, 0f);

		private static readonly Color Dark = new Color(0.16f, 0.16f, 0.16f);

		private static readonly Color Glass = new Color(0.08f, 0.12f, 0.16f);

		private static readonly Color Flame = new Color(1f, 0.55f, 0.1f);

		private static readonly Color Beacon = new Color(1f, 0.5f, 0f);

		private readonly List<Renderer> renderers = new List<Renderer>();

		private readonly List<Transform> flames = new List<Transform>();

		private bool visible = true;

		internal static CargoHauler Build(ItemDropship ship, PartBuilder parts, Transform parent, float yaw, Vector3 fallbackCenter)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_0738: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			CargoHauler cargoHauler = new CargoHauler();
			Transform val = parts.Empty(parent, "ImPostCargoHauler", Vector3.zero);
			Quaternion rotation = Quaternion.Euler(0f, yaw, 0f);
			List<Vector3> list = ((ship.ropes == null) ? new List<Vector3>() : (from r in ship.ropes
				where (Object)(object)r != (Object)null
				select ((Component)r).transform.position).ToList());
			Vector3 center = ((list.Count > 0) ? (list.Aggregate(Vector3.zero, (Vector3 a, Vector3 b) => a + b) / (float)list.Count) : fallbackCenter);
			val.position = center;
			val.rotation = rotation;
			List<Vector3> list2 = list.Select((Vector3 p) => Quaternion.Inverse(rotation) * (p - center)).ToList();
			float num = ((list2.Count > 0) ? list2.Max((Vector3 p) => Mathf.Abs(p.x)) : 1.8f) + 0.6f;
			float num2 = ((list2.Count > 0) ? list2.Max((Vector3 p) => Mathf.Abs(p.z)) : 4.4f) + 0.9f;
			num = Mathf.Clamp(num, 1.5f, 6f);
			num2 = Mathf.Clamp(num2, 2.5f, 9f);
			if (num > num2)
			{
				val.rotation = rotation * Quaternion.Euler(0f, 90f, 0f);
				list2 = ((IEnumerable<Vector3>)list2).Select((Func<Vector3, Vector3>)((Vector3 p) => new Vector3(0f - p.z, p.y, p.x))).ToList();
				float num3 = num2;
				num2 = num;
				num = num3;
			}
			Material mat = parts.Cached("hauler.yellow", Yellow, 0.55f);
			Material mat2 = parts.Cached("hauler.dark", Dark, 0.4f);
			Material mat3 = parts.Cached("van.glass", Glass, 0.95f, Glass * 0.5f);
			Material mat4 = parts.Cached("courier.flame", Flame, 0.2f, Flame * 12f);
			Material mat5 = parts.Cached("hauler.beacon", Beacon, 0.8f, Beacon * 10f);
			parts.Box(val, "Hull", new Vector3(0f, 0.95f, 0f), new Vector3(2f * num, 1.6f, 2f * num2), mat);
			parts.Box(val, "Belly", new Vector3(0f, 0.08f, 0f), new Vector3(2f * num - 0.3f, 0.16f, 2f * num2 - 0.3f), mat2);
			parts.Box(val, "RoofStripe", new Vector3(0f, 1.76f, 0f), new Vector3(0.5f, 0.02f, 2f * num2 - 0.4f), mat2);
			float num4 = Mathf.Min(2f * num, 2.4f);
			parts.Box(val, "Cockpit", new Vector3(0f, 1.15f, num2 + 0.55f), new Vector3(num4, 1.2f, 1.1f), mat);
			parts.Box(val, "Windshield", new Vector3(0f, 1.35f, num2 + 1.11f), new Vector3(num4 - 0.3f, 0.55f, 0.02f), mat3);
			parts.Box(val, "Nose", new Vector3(0f, 0.6f, num2 + 1.12f), new Vector3(num4, 0.3f, 0.06f), mat2);
			float[] array = new float[2] { -1f, 1f };
			foreach (float num6 in array)
			{
				Transform val2 = parts.Empty(val, "SideText", new Vector3(num6 * (num + 0.012f), 1.1f, 0f));
				val2.localRotation = Quaternion.Euler(0f, 90f * num6, 0f);
				parts.Text(val2, "ImPost", new Vector3(0f, 0.15f, 0f), new Vector2(2f * num2 * 0.6f, 0.9f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
				parts.Text(val2, "CARGO", new Vector3(0f, -0.5f, 0f), new Vector2(2f * num2 * 0.3f, 0.3f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
				parts.Box(val, "SideStripe", new Vector3(num6 * (num + 0.006f), 0.35f, 0f), new Vector3(0.01f, 0.12f, 2f * num2), mat2);
			}
			Transform val3 = parts.Empty(val, "RearText", new Vector3(0f, 1.1f, 0f - num2 - 0.012f));
			val3.localRotation = Quaternion.Euler(0f, 180f, 0f);
			parts.Text(val3, "ImPost", Vector3.zero, new Vector2(2f * num * 0.8f, 0.7f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
			array = new float[2] { -1f, 1f };
			Vector3 val4 = default(Vector3);
			foreach (float num7 in array)
			{
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num9 in array2)
				{
					((Vector3)(ref val4))..ctor(num7 * (num + 0.7f), 1f, num9 * (num2 - 0.6f));
					parts.Box(val, "Arm", new Vector3(num7 * (num + 0.35f), 1f, val4.z), new Vector3(0.7f, 0.18f, 0.3f), mat2);
					parts.Shape((PrimitiveType)2, val, "Pod", val4, new Vector3(0.9f, 0.3f, 0.9f), mat2);
					parts.Shape((PrimitiveType)2, val, "PodRing", val4 + Vector3.up * 0.32f, new Vector3(0.95f, 0.03f, 0.95f), mat);
					cargoHauler.flames.Add(parts.Shape((PrimitiveType)2, val, "Flame", val4 - Vector3.up * 0.55f, new Vector3(0.6f, 0.35f, 0.6f), mat4));
					parts.Shape((PrimitiveType)0, val, "Beacon", new Vector3(num7 * (num - 0.2f), 1.82f, num9 * (num2 - 0.2f)), Vector3.one * 0.18f, mat5);
				}
			}
			foreach (Vector3 item in list2)
			{
				parts.Box(val, "Winch", item + new Vector3(0f, 0.12f, 0f), new Vector3(0.35f, 0.25f, 0.35f), mat2);
			}
			val.SetParent(parent, true);
			cargoHauler.renderers.AddRange(((Component)val).GetComponentsInChildren<Renderer>(true));
			cargoHauler.SetVisible(show: false);
			return cargoHauler;
		}

		internal void SetVisible(bool show)
		{
			if (show == visible)
			{
				return;
			}
			visible = show;
			foreach (Renderer renderer in renderers)
			{
				if ((Object)(object)renderer != (Object)null)
				{
					renderer.enabled = show;
				}
			}
		}

		internal void Animate()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (visible)
			{
				for (int i = 0; i < flames.Count; i++)
				{
					Vector3 localScale = flames[i].localScale;
					localScale.y = 0.25f + 0.25f * Mathf.PerlinNoise(Time.time * 10f, (float)i * 2.3f);
					flames[i].localScale = localScale;
				}
			}
		}
	}
	public class CourierRun : MonoBehaviour
	{
		private const float ArriveTime = 6f;

		private const float FirstCycle = 7f;

		private const float CycleTime = 8f;

		private const float DepositOffset = 4.6f;

		private const float DepartTime = 8f;

		private const float HandHeight = 1f;

		private const float VanHalfLength = 2.3f;

		private static readonly Color Yellow = new Color(1f, 0.8f, 0f);

		private static readonly Color Dark = new Color(0.16f, 0.16f, 0.16f);

		private static readonly Color Interior = new Color(0.05f, 0.05f, 0.05f);

		private static readonly Color Glass = new Color(0.08f, 0.12f, 0.16f);

		private static readonly Color Cardboard = new Color(0.72f, 0.54f, 0.33f);

		private static readonly Color Tape = new Color(0.86f, 0.74f, 0.52f);

		private static readonly Color Visor = new Color(0.2f, 0.85f, 1f);

		private static readonly Color Flame = new Color(1f, 0.55f, 0.1f);

		private static readonly Color HeadLight = new Color(1f, 0.97f, 0.85f);

		private static readonly Color TailLight = new Color(1f, 0.1f, 0.05f);

		private PaczkomatController controller;

		private List<PaczkomatController.Locker> targets;

		private float startTime;

		private PartBuilder parts;

		private Transform van;

		private Transform leftDoor;

		private Transform rightDoor;

		private readonly List<Transform> vanFlames = new List<Transform>();

		private Vector3 vanStart;

		private Vector3 vanApproach;

		private Vector3 vanSpot;

		private Vector3 vanLeave;

		private Vector3 vanEnd;

		private Quaternion vanRotation;

		private Vector3 lastVanPosition;

		private Transform bot;

		private Transform hands;

		private readonly List<Transform> botFlames = new List<Transform>();

		private Vector3 rearPoint;

		private Vector3 cargoPoint;

		private float botYaw;

		private Vector3 lastBotPosition;

		private readonly List<Transform> parcels = new List<Transform>();

		private readonly List<Vector3> hoverPoints = new List<Vector3>();

		private readonly List<Vector3> lockerPoints = new List<Vector3>();

		private readonly bool[] lockerOpened = new bool[16];

		internal static float DepositTime(int index)
		{
			return 7f + (float)index * 8f + 4.6f;
		}

		internal static float Duration(int orders)
		{
			return 7f + (float)orders * 8f + 8f;
		}

		internal void Init(PaczkomatController owner, List<PaczkomatController.Locker> lockers)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			controller = owner;
			targets = lockers;
			parts = owner.Parts;
			startTime = Time.time;
			((Component)this).transform.SetParent(owner.Model.parent, true);
			Transform model = owner.Model;
			float x = model.lossyScale.x;
			Vector3 forward = model.forward;
			Vector3 right = model.right;
			float y = model.position.y;
			Vector3 val = model.position + right * owner.HalfWidthWorld;
			vanSpot = val + right * 3.6999998f + forward * (PaczkomatController.FrontZ * x + 1.8f);
			vanSpot.y = y;
			vanRotation = Quaternion.LookRotation(right, Vector3.up);
			rearPoint = vanSpot - right * 3.1f;
			cargoPoint = vanSpot - right * 1.4f + Vector3.up * 0.53f;
			vanStart = vanSpot + Vector3.up * 45f + right * 30f + forward * 20f;
			vanApproach = vanSpot + Vector3.up * 14f + right * 8f;
			vanLeave = vanSpot + Vector3.up * 12f + right * 4f;
			vanEnd = vanSpot + Vector3.up * 55f + right * 15f - forward * 35f;
			foreach (PaczkomatController.Locker locker in lockers)
			{
				Vector3 val2 = model.TransformPoint(locker.Center);
				Vector3 item = val2 + forward * 0.8f;
				item.y = Mathf.Max(y + 0.05f, val2.y - 1f);
				hoverPoints.Add(item);
				lockerPoints.Add(val2 - forward * 0.12f);
			}
			BuildVan();
			BuildBot();
			BuildParcels(x);
			van.position = vanStart;
			van.rotation = vanRotation;
			lastVanPosition = vanStart;
			((Component)bot).gameObject.SetActive(false);
		}

		private void BuildVan()
		{
			//IL_000b: 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_0055: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0891: Unknown result type (might be due to invalid IL or missing references)
			//IL_0896: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Unknown result type (might be due to invalid IL or missing references)
			//IL_0947: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcd: Unknown result type (might be due to invalid IL or missing references)
			Material mat = parts.Cached("van.yellow", Yellow, 0.55f);
			Material mat2 = parts.Cached("van.dark", Dark, 0.4f);
			Material mat3 = parts.Cached("van.interior", Interior, 0.1f);
			Material mat4 = parts.Cached("van.glass", Glass, 0.95f, Glass * 0.5f);
			Material mat5 = parts.Cached("van.head", HeadLight, 0.9f, HeadLight * 10f);
			Material mat6 = parts.Cached("van.tail", TailLight, 0.9f, TailLight * 6f);
			Material mat7 = parts.Cached("courier.flame", Flame, 0.2f, Flame * 12f);
			Material mat8 = parts.Cached("van.grey", new Color(0.55f, 0.55f, 0.55f), 0.7f);
			van = parts.Empty(((Component)this).transform, "Van", Vector3.zero);
			parts.Box(van, "Floor", new Vector3(0f, 0.49f, -0.7f), new Vector3(2f, 0.08f, 3.2f), mat2);
			parts.Box(van, "Roof", new Vector3(0f, 2.41f, -0.7f), new Vector3(2f, 0.08f, 3.2f), mat);
			parts.Box(van, "WallL", new Vector3(-0.97f, 1.45f, -0.7f), new Vector3(0.06f, 2f, 3.2f), mat);
			parts.Box(van, "WallR", new Vector3(0.97f, 1.45f, -0.7f), new Vector3(0.06f, 2f, 3.2f), mat);
			parts.Box(van, "WallFront", new Vector3(0f, 1.45f, 0.87f), new Vector3(2f, 2f, 0.06f), mat);
			parts.Box(van, "LiningL", new Vector3(-0.935f, 1.45f, -0.7f), new Vector3(0.01f, 1.84f, 3.1f), mat3);
			parts.Box(van, "LiningR", new Vector3(0.935f, 1.45f, -0.7f), new Vector3(0.01f, 1.84f, 3.1f), mat3);
			parts.Box(van, "LiningTop", new Vector3(0f, 2.365f, -0.7f), new Vector3(1.86f, 0.01f, 3.1f), mat3);
			parts.Box(van, "LiningFront", new Vector3(0f, 1.45f, 0.835f), new Vector3(1.86f, 1.84f, 0.01f), mat3);
			parts.Box(van, "Cab", new Vector3(0f, 1.15f, 1.55f), new Vector3(1.96f, 1.4f, 1.3f), mat);
			parts.Box(van, "Windshield", new Vector3(0f, 1.48f, 2.205f), new Vector3(1.7f, 0.58f, 0.02f), mat4);
			parts.Box(van, "WindowL", new Vector3(-0.985f, 1.48f, 1.65f), new Vector3(0.02f, 0.5f, 0.9f), mat4);
			parts.Box(van, "WindowR", new Vector3(0.985f, 1.48f, 1.65f), new Vector3(0.02f, 0.5f, 0.9f), mat4);
			parts.Box(van, "Bumper", new Vector3(0f, 0.6f, 2.25f), new Vector3(2f, 0.36f, 0.14f), mat2);
			parts.Box(van, "BumperRear", new Vector3(0f, 0.5f, -2.33f), new Vector3(2f, 0.2f, 0.1f), mat2);
			parts.Box(van, "Underbody", new Vector3(0f, 0.42f, 0f), new Vector3(1.9f, 0.12f, 4.4f), mat2);
			float[] array = new float[2] { -0.7f, 0.7f };
			foreach (float num in array)
			{
				parts.Box(van, "HeadLight", new Vector3(num, 0.88f, 2.215f), new Vector3(0.32f, 0.15f, 0.02f), mat5);
			}
			array = new float[2] { -0.92f, 0.92f };
			foreach (float num2 in array)
			{
				parts.Box(van, "TailLight", new Vector3(num2, 1f, -2.31f), new Vector3(0.12f, 0.32f, 0.02f), mat6);
			}
			array = new float[2] { -1f, 1f };
			foreach (float num3 in array)
			{
				float[] array2 = new float[2] { -1.45f, 1.45f };
				foreach (float num4 in array2)
				{
					parts.Shape((PrimitiveType)2, van, "Wheel", new Vector3(num3, 0.38f, num4), new Vector3(0.76f, 0.12f, 0.76f), mat2).localRotation = Quaternion.Euler(0f, 0f, 90f);
					parts.Shape((PrimitiveType)2, van, "Hub", new Vector3(num3 * 1.06f, 0.38f, num4), new Vector3(0.36f, 0.02f, 0.36f), mat8).localRotation = Quaternion.Euler(0f, 0f, 90f);
				}
			}
			parts.Box(van, "StripeL", new Vector3(-1.005f, 0.95f, -0.2f), new Vector3(0.01f, 0.1f, 4.2f), mat2);
			parts.Box(van, "StripeR", new Vector3(1.005f, 0.95f, -0.2f), new Vector3(0.01f, 0.1f, 4.2f), mat2);
			array = new float[2] { -1f, 1f };
			foreach (float num5 in array)
			{
				Transform val = parts.Empty(van, "SideText", new Vector3(num5 * 1.012f, 1.6f, -0.7f));
				val.localRotation = Quaternion.Euler(0f, 90f * num5, 0f);
				parts.Text(val, "ImPost", Vector3.zero, new Vector2(2.4f, 0.6f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
				parts.Text(val, L.VanSlogan, new Vector3(0f, -0.42f, 0f), new Vector2(2.2f, 0.2f), Dark, (TextAlignmentOptions)514, (FontStyles)0);
			}
			leftDoor = parts.Empty(van, "DoorL", new Vector3(-1f, 1.45f, -2.32f));
			parts.Box(leftDoor, "Panel", new Vector3(0.5f, 0f, -0.02f), new Vector3(0.98f, 1.9f, 0.04f), mat);
			parts.Box(leftDoor, "Window", new Vector3(0.5f, 0.45f, -0.041f), new Vector3(0.6f, 0.4f, 0.005f), mat4);
			parts.Box(leftDoor, "Handle", new Vector3(0.88f, 0f, -0.05f), new Vector3(0.05f, 0.2f, 0.03f), mat2);
			rightDoor = parts.Empty(van, "DoorR", new Vector3(1f, 1.45f, -2.32f));
			parts.Box(rightDoor, "Panel", new Vector3(-0.5f, 0f, -0.02f), new Vector3(0.98f, 1.9f, 0.04f), mat);
			parts.Box(rightDoor, "Window", new Vector3(-0.5f, 0.45f, -0.041f), new Vector3(0.6f, 0.4f, 0.005f), mat4);
			Transform val2 = parts.Empty(rightDoor, "RearText", new Vector3(-0.5f, -0.25f, -0.045f));
			val2.localRotation = Quaternion.Euler(0f, 180f, 0f);
			parts.Text(val2, "ImPost", Vector3.zero, new Vector2(0.8f, 0.25f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
			array = new float[2] { -0.75f, 0.75f };
			foreach (float num6 in array)
			{
				float[] array2 = new float[2] { -1.6f, 1.6f };
				foreach (float num7 in array2)
				{
					parts.Shape((PrimitiveType)2, van, "Thruster", new Vector3(num6, 0.3f, num7), new Vector3(0.3f, 0.06f, 0.3f), mat2);
					vanFlames.Add(parts.Shape((PrimitiveType)2, van, "Flame", new Vector3(num6, 0.05f, num7), new Vector3(0.22f, 0.2f, 0.22f), mat7));
				}
			}
		}

		private void BuildBot()
		{
			//IL_000b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			Material mat = parts.Cached("courier.yellow", Yellow, 0.45f);
			Material mat2 = parts.Cached("courier.dark", Dark, 0.4f);
			Material mat3 = parts.Cached("courier.visor", Visor * 0.3f, 0.9f, Visor * 6f);
			Material mat4 = parts.Cached("courier.flame", Flame, 0.2f, Flame * 12f);
			bot = parts.Empty(((Component)this).transform, "CourierBot", Vector3.zero);
			parts.Shape((PrimitiveType)2, bot, "Base", new Vector3(0f, 0.55f, 0f), new Vector3(0.42f, 0.12f, 0.42f), mat2);
			parts.Shape((PrimitiveType)0, bot, "Hips", new Vector3(0f, 0.72f, 0f), new Vector3(0.4f, 0.3f, 0.34f), mat2);
			parts.Box(bot, "Torso", new Vector3(0f, 1.05f, 0f), new Vector3(0.56f, 0.58f, 0.36f), mat);
			parts.Text(bot, "ImPost", new Vector3(0f, 1.18f, 0.181f), new Vector2(0.42f, 0.1f), Dark, (TextAlignmentOptions)514, (FontStyles)1);
			parts.Box(bot, "Neck", new Vector3(0f, 1.38f, 0f), new Vector3(0.14f, 0.1f, 0.14f), mat2);
			parts.Box(bot, "Head", new Vector3(0f, 1.56f, 0f), new Vector3(0.4f, 0.3f, 0.34f), mat2);
			parts.Box(bot, "Visor", new Vector3(0f, 1.58f, 0.171f), new Vector3(0.32f, 0.1f, 0.01f), mat3);
			parts.Box(bot, "Cap", new Vector3(0f, 1.75f, -0.01f), new Vector3(0.42f, 0.09f, 0.36f), mat);
			parts.Box(bot, "CapBrim", new Vector3(0f, 1.72f, 0.22f), new Vector3(0.4f, 0.025f, 0.14f), mat);
			float[] array = new float[2] { -0.34f, 0.34f };
			foreach (float num in array)
			{
				Transform val = parts.Empty(bot, "Arm", new Vector3(num, 1.25f, 0.05f));
				val.localRotation = Quaternion.Euler(70f, 0f, 0f);
				parts.Box(val, "UpperArm", new Vector3(0f, -0.2f, 0f), new Vector3(0.12f, 0.42f, 0.12f), mat);
				parts.Box(val, "Hand", new Vector3(0f, -0.44f, 0f), new Vector3(0.1f, 0.08f, 0.14f), mat2);
			}
			hands = parts.Empty(bot, "Hands", new Vector3(0f, 1f, 0.5f));
			parts.Box(bot, "Jetpack", new Vector3(0f, 1.08f, -0.29f), new Vector3(0.42f, 0.46f, 0.2f), mat2);
			array = new float[2] { -0.12f, 0.12f };
			foreach (float num2 in array)
			{
				parts.Shape((PrimitiveType)2, bot, "Nozzle", new Vector3(num2, 0.8f, -0.29f), new Vector3(0.1f, 0.06f, 0.1f), mat);
				botFlames.Add(parts.Shape((PrimitiveType)2, bot, "Flame", new Vector3(num2, 0.62f, -0.29f), new Vector3(0.07f, 0.13f, 0.07f), mat4));
			}
			botFlames.Add(parts.Shape((PrimitiveType)2, bot, "BaseFlame", new Vector3(0f, 0.4f, 0f), new Vector3(0.22f, 0.12f, 0.22f), mat4));
		}

		private void BuildParcels(float scale)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			Material mat = parts.Cached("courier.cardboard", Cardboard, 0.15f);
			Material mat2 = parts.Cached("courier.tape", Tape, 0.3f);
			Material mat3 = parts.Cached("courier.yellow", Yellow, 0.45f);
			for (int i = 0; i < targets.Count; i++)
			{
				float num = targets[i].Height * scale;
				float num2 = PaczkomatController.CellWidthModel * scale;
				float num3 = Mathf.Min(new float[3]
				{
					1f,
					num * 0.75f / 0.3f,
					num2 * 0.8f / 0.42f
				});
				Transform val = parts.Empty(van, "Parcel", new Vector3(-0.5f + (float)(i % 3) * 0.5f, 0.53f + 0.15f * num3 + (float)(i / 3) * 0.34f, -1.6f + (float)(i % 2) * 0.3f));
				val.localScale = Vector3.one * num3;
				parts.Box(val, "Box", Vector3.zero, new Vector3(0.42f, 0.3f, 0.34f), mat);
				parts.Box(val, "TapeTop", new Vector3(0f, 0.151f, 0f), new Vector3(0.07f, 0.004f, 0.345f), mat2);
				parts.Box(val, "TapeFront", new Vector3(0f, 0f, 0.171f), new Vector3(0.07f, 0.3f, 0.004f), mat2);
				parts.Box(val, "Label", new Vector3(0.11f, 0.05f, 0.172f), new Vector3(0.14f, 0.09f, 0.003f), mat3);
				parcels.Add(val);
			}
		}

		private void Update()
		{
			if ((Object)(object)controller == (Object)null || (Object)(object)controller.Model == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float num = Time.time - startTime;
			int count = targets.Count;
			if (num >= Duration(count))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float cyclesEnd = 7f + (float)count * 8f;
			UpdateVan(num, cyclesEnd);
			UpdateDoors(num, cyclesEnd);
			UpdateBot(num, cyclesEnd);
			Flicker(vanFlames, 0.12f, 0.3f, 0f);
			Flicker(botFlames, 0.08f, 0.1f, 5f);
		}

		private void UpdateVan(float t, float cyclesEnd)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			//IL_0048: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			float num = cyclesEnd + 2f;
			Vector3 val;
			if (t < 6f)
			{
				val = Bezier(vanStart, vanApproach, vanSpot, EaseOut(t / 6f));
			}
			else if (t < num)
			{
				val = vanSpot;
				flag = false;
			}
			else
			{
				val = Bezier(vanSpot, vanLeave, vanEnd, EaseIn((t - num) / 6f));
			}
			Vector3 val2 = (val - lastVanPosition) / Mathf.Max(Time.deltaTime, 0.0001f);
			lastVanPosition = val;
			van.position = val;
			Vector3 val3 = Quaternion.Inverse(vanRotation) * val2;
			float num2 = Mathf.Clamp(val3.z * 0.6f, -12f, 12f);
			float num3 = Mathf.Clamp((0f - val3.x) * 0.6f, -12f, 12f);
			van.rotation = vanRotation * Quaternion.Euler(num2, 0f, num3);
			foreach (Transform vanFlame in vanFlames)
			{
				((Component)vanFlame).gameObject.SetActive(flag || t < 6.3f);
			}
		}

		private void UpdateDoors(float t, float cyclesEnd)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			float num = ((t < 6f) ? 0f : ((t < 7f) ? Mathf.SmoothStep(0f, 1f, (t - 6f) / 1f) : ((!(t < cyclesEnd + 0.6f)) ? (1f - Mathf.SmoothStep(0f, 1f, (t - cyclesEnd - 0.6f) / 1f)) : 1f)));
			float num2 = 100f * num;
			leftDoor.localRotation = Quaternion.Euler(0f, num2, 0f);
			rightDoor.localRotation = Quaternion.Euler(0f, 0f - num2, 0f);
		}

		private void UpdateBot(float t, float cyclesEnd)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = -(vanRotation * Vector3.forward);
			bool flag = t >= 6.4f && t < cyclesEnd + 0.7f;
			((Component)bot).gameObject.SetActive(flag);
			if (flag)
			{
				Vector3 pos;
				Vector3 face;
				if (t < 7f)
				{
					float num = Mathf.SmoothStep(0f, 1f, (t - 6f - 0.4f) / 0.6f);
					pos = Vector3.Lerp(cargoPoint, rearPoint, num);
					face = val;
				}
				else if (t >= cyclesEnd)
				{
					float num2 = Mathf.SmoothStep(0f, 1f, (t - cyclesEnd) / 0.7f);
					pos = Vector3.Lerp(rearPoint, cargoPoint, num2);
					face = -val;
				}
				else
				{
					int num3 = Mathf.Min((int)((t - 7f) / 8f), targets.Count - 1);
					float c = t - 7f - (float)num3 * 8f;
					UpdateCycle(num3, c, out pos, out face);
				}
				pos.y += Mathf.Sin(Time.time * 3.1f) * 0.03f;
				bot.position = pos;
				Vector3 val2 = new Vector3(face.x, 0f, face.z);
				Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized + Vector3.forward * 0.0001f);
				float y = ((Quaternion)(ref val3)).eulerAngles.y;
				botYaw = Mathf.MoveTowardsAngle(botYaw, y, 300f * Time.deltaTime);
				Vector3 val4 = (pos - lastBotPosition) / Mathf.Max(Time.deltaTime, 0.0001f);
				lastBotPosition = pos;
				val2 = new Vector3(val4.x, 0f, val4.z);
				float num4 = Mathf.Clamp(((Vector3)(ref val2)).magnitude * 4f, 0f, 12f);
				bot.rotation = Quaternion.Euler(num4, botYaw, 0f);
			}
		}

		private void UpdateCycle(int i, float c, out Vector3 pos, out Vector3 face)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: 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)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = hoverPoints[i];
			Vector3 val2 = -(vanRotation * Vector3.forward);
			Vector3 val3 = -controller.Model.forward;
			Transform val4 = parcels[i];
			if (c < 0.6f)
			{
				pos = rearPoint;
				face = -val2;
				if ((Object)(object)val4 != (Object)null)
				{
					if ((Object)(object)val4.parent == (Object)(object)van)
					{
						val4.SetParent(((Component)this).transform, true);
					}
					val4.position = Vector3.Lerp(val4.position, hands.position, Mathf.Clamp01(c / 0.6f));
					val4.rotation = Quaternion.Slerp(val4.rotation, hands.rotation, Mathf.Clamp01(c / 0.6f));
				}
			}
			else if (c < 2.8f)
			{
				float num = Mathf.SmoothStep(0f, 1f, (c - 0.6f) / 2.2f);
				pos = Vector3.Lerp(rearPoint, val, num);
				pos.y = Mathf.Lerp(rearPoint.y, val.y, Mathf.SmoothStep(0f, 1f, num * 1.3f));
				face = ((c > 2.4f) ? val3 : (val - rearPoint));
				Hold(val4);
			}
			else if (c < 5.2f)
			{
				pos = val;
				face = val3;
				if (!lockerOpened[i])
				{
					lockerOpened[i] = true;
					controller.OpenLocker(targets[i].Index, 2.2f);
				}
				if ((Object)(object)val4 != (Object)null)
				{
					if (c < 3.2f)
					{
						Hold(val4);
					}
					else if (c < 4.6f)
					{
						float num2 = Mathf.SmoothStep(0f, 1f, (c - 3.2f) / 1.3999999f);
						val4.position = Vector3.Lerp(hands.position, lockerPoints[i], num2);
						val4.rotation = Quaternion.LookRotation(val3);
					}
					else
					{
						Object.Destroy((Object)(object)((Component)val4).gameObject);
						parcels[i] = null;
					}
				}
			}
			else
			{
				float num3 = Mathf.SmoothStep(0f, 1f, (c - 5.2f) / 2.4f);
				pos = Vector3.Lerp(val, rearPoint, num3);
				pos.y = Mathf.Lerp(val.y, rearPoint.y, Mathf.SmoothStep(0f, 1f, num3 * 1.3f));
				face = ((num3 > 0.9f) ? (-val2) : (rearPoint - val));
			}
		}

		private void Hold(Transform parcel)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)parcel != (Object)null)
			{
				parcel.position = hands.position;
				parcel.rotation = hands.rotation;
			}
		}

		private static void Flicker(List<Transform> flames, float min, float range, float seed)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < flames.Count; i++)
			{
				Vector3 localScale = flames[i].localScale;
				localScale.y = min + range * Mathf.PerlinNoise(Time.time * 12f, seed + (float)i * 3.7f);
				flames[i].localScale = localScale;
			}
		}

		private static Vector3 Bezier(Vector3 a, Vector3 b, Vector3 c, float t)
		{
			//IL_000b: 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_001a: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - t;
			return num * num * a + 2f * num * t * b + t * t * c;
		}

		private static float EaseOut(float t)
		{
			return 1f - (1f - t) * (1f - t);
		}

		private static float EaseIn(float t)
		{
			return t * t;
		}
	}
	public class ImPostManager : MonoBehaviour
	{
		private const int MaxItemsPerOrder = 12;

		private const int KeepPickedUp = 15;

		internal static ImPostManager Instance;

		internal static ulong? LastTerminalBuyer;

		private static readonly Random Rng = new Random();

		internal readonly List<Order> Orders = new List<Order>();

		internal Action<bool, int, FailReason> BuyCallback;

		internal Action<bool, int, FailReason> PickupCallback;

		private int nextOrderId = 1;

		private Terminal terminal;

		private readonly List<KeyValuePair<string, string>> pendingSms = new List<KeyValuePair<string, string>>();

		internal bool Parked { get; private set; }

		internal bool HasState { get; private set; }

		internal string PhoneNumber { get; private set; }

		internal Terminal Terminal
		{
			get
			{
				if ((Object)(object)terminal == (Object)null)
				{
					terminal = Object.FindObjectOfType<Terminal>();
				}
				return terminal;
			}
		}

		private void Start()
		{
			Instance = this;
			PhoneNumber = RandomPhoneNumber();
			ImPostNetwork.Register();
			((Component)this).gameObject.AddComponent<PhoneApp>();
			if (ImPostNetwork.IsServer)
			{
				HasState = true;
			}
			else
			{
				ImPostNetwork.RequestStateFromServer();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void Update()
		{
			if (ImPostNetwork.IsServer)
			{
				ConsumeTerminalOrders();
			}
			if (pendingSms.Count <= 0 || InsideFacility())
			{
				return;
			}
			foreach (KeyValuePair<string, string> pendingSm in pendingSms)
			{
				DisplaySms(pendingSm.Key, pendingSm.Value);
			}
			pendingSms.Clear();
		}

		private static bool InsideFacility()
		{
			PlayerControllerB localPlayer = UiKit.LocalPlayer;
			if ((Object)(object)localPlayer != (Object)null && localPlayer.isInsideFactory)
			{
				return !localPlayer.isPlayerDead;
			}
			return false;
		}

		internal void RequestState()
		{
			if (!ImPostNetwork.IsServer)
			{
				ImPostNetwork.RequestStateFromServer();
			}
		}

		internal void ConsumeTerminalOrders()
		{
			Terminal val = Terminal;
			if (!((Object)(object)val == (Object)null) && val.orderedItemsFromTerminal != null && val.orderedItemsFromTerminal.Count != 0)
			{
				int[] items = val.orderedItemsFromTerminal.ToArray();
				val.orderedItemsFromTerminal.Clear();
				val.numberOfItemsInDropship = 0;
				val.SyncGroupCreditsClientRpc(val.groupCredits, 0);
				ulong clientId = LastTerminalBuyer ?? NetworkManager.Singleton.LocalClientId;
				LastTerminalBuyer = null;
				CreateOrder(items, PlayerName(clientId));
			}
		}

		private static string PlayerName(ulong clientId)
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return "";
			}
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.actualClientId == clientId && (val.isPlayerControlled || val.isPlayerDead))
				{
					return val.playerUsername;
				}
			}
			return "";
		}

		internal void ServerBuy(ulong clientId, int[] items)
		{
			Terminal t = Terminal;
			FailReason failReason = FailReason.None;
			int num = 0;
			if ((Object)(object)t == (Object)null || items == null || items.Length == 0 || items.Any((int i) => i < 0 || i >= t.buyableItemsList.Length))
			{
				failReason = FailReason.Invalid;
			}
			else if (items.Length > 12)
			{
				failReason = FailReason.TooManyItems;
			}
			else
			{
				num = ((IEnumerable<int>)items).Sum((Func<int, int>)Price);
				if (num > t.groupCredits)
				{
					failReason = FailReason.NotEnoughCredits;
				}
			}
			int orderId = -1;
			if (failReason == FailReason.None)
			{
				Terminal obj = t;
				obj.groupCredits -= num;
				t.SyncGroupCreditsClientRpc(t.groupCredits, -1);
				orderId = CreateOrder(items, PlayerName(clientId)).Id;
			}
			bool ok = failReason == FailReason.None;
			if (clientId == NetworkManager.Singleton.LocalClientId)
			{
				OnBuyResult(ok, orderId, failReason);
			}
			else
			{
				ImPostNetwork.SendBuyResult(clientId, ok, orderId, failReason);
			}
		}

		internal void ServerPickup(ulong clientId, string code)
		{
			PaczkomatController current = PaczkomatController.Current;
			Order order = Orders.FirstOrDefault((Order o) => o.Status == OrderStatus.AwaitingPickup && o.Code == code);
			FailReason failReason = FailReason.None;
			if ((Object)(object)current == (Object)null || !Parked)
			{
				failReason = FailReason.NotReady;
			}
			else if (order == null)
			{
				failReason = FailReason.WrongCode;
			}
			int locker = -1;
			if (failReason == FailReason.None)
			{
				current.ServerHandOver(order);
				locker = order.Locker + 1;
				order.Status = OrderStatus.PickedUp;
				TrimHistory();
				BroadcastState();
			}
			bool ok = failReason == FailReason.None;
			if (clientId == NetworkManager.Singleton.LocalClientId)
			{
				OnPickupResult(ok, locker, failReason);
			}
			else
			{
				ImPostNetwork.SendPickupResult(clientId, ok, locker, failReason);
			}
		}

		internal void ServerSetParked(bool parked)
		{
			if (Parked != parked)
			{
				Parked = parked;
				BroadcastState();
			}
		}

		internal void ServerDispatchCourier(List<Order> orders, int[] lockers)
		{
			for (int i = 0; i < orders.Count; i++)
			{
				orders[i].Status = OrderStatus.OutForDelivery;
				orders[i].Locker = lockers[i];
			}
			BroadcastState();
			PaczkomatController.Current?.PlayCourier(lockers);
			ImPostNetwork.BroadcastCourier(lockers);
		}

		internal void ServerParcelDeposited(Order order)
		{
			order.Status = OrderStatus.AwaitingPickup;
			BroadcastState();
			if (Plugin.SmsEnabled.Value)
			{
				ShowSms(Plugin.SmsText.Value, order.Code);
				ImPostNetwork.BroadcastSms(Plugin.SmsText.Value, order.Code);
			}
		}

		internal void ServerLockerGone()
		{
			foreach (Order item in Orders.Where((Order o) => o.Status == OrderStatus.OutForDelivery))
			{
				item.Status = OrderStatus.Ordered;
				item.Locker = -1;
				item.ReadyAt = Time.time;
			}
			Parked = false;
			BroadcastState();
		}

		internal static int Price(int itemIndex)
		{
			Terminal val = Instance?.Terminal;
			if ((Object)(object)val == (Object)null || itemIndex < 0 || itemIndex >= val.buyableItemsList.Length)
			{
				return 0;
			}
			int num = ((val.itemSalesPercentages != null && itemIndex < val.itemSalesPercentages.Length) ? val.itemSalesPercentages[itemIndex] : 100);
			return (int)((float)val.buyableItemsList[itemIndex].creditsWorth * ((float)num / 100f));
		}

		private Order CreateOrder(int[] items, string buyer)
		{
			Order order = new Order
			{
				Id = nextOrderId++,
				Status = OrderStatus.Ordered,
				Code = UniqueCode(),
				Items = items,
				Buyer = buyer,
				ReadyAt = Time.time + Mathf.Max(0f, Plugin.CourierDelay.Value)
			};
			Orders.Add(order);
			TrimHistory();
			BroadcastState();
			return order;
		}

		private string UniqueCode()
		{
			string code;
			do
			{
				code = Rng.Next(0, 10000).ToString("D4");
			}
			while (Orders.Any((Order o) => o.Status != OrderStatus.PickedUp && o.Code == code));
			return code;
		}

		private void TrimHistory()
		{
			List<Order> list = Orders.Where((Order o) => o.Status == OrderStatus.PickedUp).ToList();
			for (int num = 0; num < list.Count - 15; num++)
			{
				Orders.Remove(list[num]);
			}
		}

		private void BroadcastState()
		{
			HasState = true;
			ImPostNetwork.BroadcastState(this);
		}

		internal void ApplyState(bool parked, List<Order> orders)
		{
			Parked = parked;
			Orders.Clear();
			Orders.AddRange(orders);
			HasState = true;
		}

		internal void RequestBuy(int[] items, Action<bool, int, FailReason> callback)
		{
			BuyCallback = callback;
			if (ImPostNetwork.IsServer)
			{
				ServerBuy(NetworkManager.Singleton.LocalClientId, items);
			}
			else
			{
				ImPostNetwork.SendBuy(items);
			}
		}

		internal void RequestPickup(string code, Action<bool, int, FailReason> callback)
		{
			PickupCallback = callback;
			if (ImPostNetwork.IsServer)
			{
				ServerPickup(NetworkManager.Singleton.LocalClientId, code);
			}
			else
			{
				ImPostNetwork.SendPickup(code);
			}
		}

		internal void OnBuyResult(bool ok, int orderId, FailReason reason)
		{
			Action<bool, int, FailReason> buyCallback = BuyCallback;
			BuyCallback = null;
			buyCallback?.Invoke(ok, orderId, reason);
		}

		internal void OnPickupResult(bool ok, int locker, FailReason reason)
		{
			Action<bool, int, FailReason> pickupCallback = PickupCallback;
			PickupCallback = null;
			pickupCallback?.Invoke(ok, locker, reason);
		}

		internal void ShowSms(string template, string code)
		{
			if (InsideFacility())
			{
				pendingSms.Add(new KeyValuePair<string, string>(template, code));
			}
			else
			{
				DisplaySms(template, code);
			}
		}

		private void DisplaySms(string template, string code)
		{
			HUDManager instance = HUDManager.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				if (string.IsNullOrEmpty(template))
				{
					template = L.SmsDefault;
				}
				string text = template.Replace("{code}", code).Replace("{kod}", code);
				instance.DisplayTip(L.SmsTitle, text, false, false, "LC_Tip1");
				string text2 = "<color=#FFCD00>ImPost SMS:</color> <color=#FFFFFF>" + template.Replace("{code}", "<color=#FFCD00><b>" + code + "</b></color>").Replace("{kod}", "<color=#FFCD00><b>" + code + "</b></color>") + "</color>";
				AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null)?.Invoke(instance, new object[4] { text2, "", -1, false });
			}
		}

		private static string RandomPhoneNumber()
		{
			int num = (new int[4] { 5, 6, 7, 8 })[Rng.Next(4)];
			return $"+48 {num}{Rng.Next(10, 100)} {Rng.Next(0, 1000):D3} {Rng.Next(0, 1000):D3}";
		}
	}
	internal static class ImPostNetwork
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static HandleNamedMessageDelegate <>9__13_0;

			public static HandleNamedMessageDelegate <>9__13_1;

			public static HandleNamedMessageDelegate <>9__13_2;

			public static HandleNamedMessageDelegate <>9__13_3;

			public static HandleNamedMessageDelegate <>9__13_4;

			public static HandleNamedMessageDelegate <>9__13_5;

			public static HandleNamedMessageDelegate <>9__13_6;

			public static HandleNamedMessageDelegate <>9__13_7;

			public static HandleNamedMessageDelegate <>9__13_8;

			public static Action<FastBufferWriter> <>9__24_0;

			internal void <Register>b__13_0(ulong sender, FastBufferReader reader)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				if (FromServer(sender))
				{
					bool parked = default(bool);
					((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref parked, default(ForPrimitives));
					Manager?.ApplyState(parked, Order.ReadList(reader));
				}
			}

			internal void <Register>b__13_1(ulong sender, FastBufferReader reader)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				if (FromServer(sender))
				{
					int val = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref val, default(ForPrimitives));
					int[] array = new int[Math.Max(0, Math.Min(val, 64))];
					for (int i = 0; i < array.Length; i++)
					{
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref array[i], default(ForPrimitives));
					}
					PaczkomatController.Current?.PlayCourier(array);
				}
			}

			internal void <Register>b__13_2(ulong sender, FastBufferReader reader)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				if (FromServer(sender))
				{
					int lockerIndex = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref lockerIndex, default(ForPrimitives));
					float seconds = default(float);
					((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref seconds, default(ForPrimitives));
					PaczkomatController.Current?.OpenLocker(lockerIndex, seconds);
				}
			}

			internal void <Register>b__13_3(ulong sender, FastBufferReader reader)
			{
				if (FromServer(sender))
				{
					string template = default(string);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref template, false);
					string code = default(string);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref code, false);
					Manager?.ShowSms(template, code);
				}
			}

			internal void <Register>b__13_4(ulong sender, FastBufferReader reader)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				if (FromServer(sender))
				{
					bool ok = default(bool);
					((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ok, default(ForPrimitives));
					int orderId = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref orderId, default(ForPrimitives));
					byte reason = default(byte);
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref reason, default(ForPrimitives));
					Manager?.OnBuyResult(ok, orderId, (FailReason)reason);
				}
			}

			internal void <Register>b__13_5(ulong sender, FastBufferReader reader)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				if (FromServer(sender))
				{
					bool ok = default(bool);
					((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ok, default(ForPrimitives));
					int locker = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref locker, default(ForPrimitives));
					byte reason = default(byte);
					((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref reason, default(ForPrimitives));
					Manager?.OnPickupResult(ok, locker, (FailReason)reason);
				}
			}

			internal void <Register>b__13_6(ulong sender, FastBufferReader reader)
			{
				if (IsServer)
				{
					SendState(sender, Manager);
				}
			}

			internal void <Register>b__13_7(ulong sender, FastBufferReader reader)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (!IsServer || (Object)(object)Manager == (Object)null)
				{
					return;
				}
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				if (num >= 0 && num <= 64)
				{
					int[] array = new int[num];
					for (int i = 0; i < num; i++)
					{
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref array[i], default(ForPrimitives));
					}
					Manager.ServerBuy(sender, array);
				}
			}

			internal void <Register>b__13_8(ulong sender, FastBufferReader reader)
			{
				if (IsServer && (Object)(object)Manager != (Object)null)
				{
					string code = default(string);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref code, false);
					Manager.ServerPickup(sender, code);
				}
			}

			internal void <RequestStateFromServer>b__24_0(FastBufferWriter w)
			{
			}
		}

		private const string State = "miniSpoXster77.UFO_ImPost.State";

		private const string Courier = "miniSpoXster77.UFO_ImPost.Courier";

		private const string LockerOpen = "miniSpoXster77.UFO_ImPost.Locker";

		private const string Sms = "miniSpoXster77.UFO_ImPost.Sms";

		private const string BuyResult = "miniSpoXster77.UFO_ImPost.BuyResult";

		private const string PickupResult = "miniSpoXster77.UFO_ImPost.PickupResult";

		private const string RequestState = "miniSpoXster77.UFO_ImPost.RequestState";

		private const string Buy = "miniSpoXster77.UFO_ImPost.Buy";

		private const string Pickup = "miniSpoXster77.UFO_ImPost.Pickup";

		private static NetworkManager Net => NetworkManager.Singleton;

		internal static bool IsServer
		{
			get
			{
				if ((Object)(object)Net != (Object)null)
				{
					return Net.IsServer;
				}
				return false;
			}
		}

		private static ImPostManager Manager => ImPostManager.Instance;

		internal static void Register()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			NetworkManager net = Net;
			CustomMessagingManager val = ((net != null) ? net.CustomMessagingManager : null);
			if (val == null)
			{
				return;
			}
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					if (FromServer(sender))
					{
						bool parked = default(bool);
						((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref parked, default(ForPrimitives));
						Manager?.ApplyState(parked, Order.ReadList(reader));
					}
				};
				<>c.<>9__13_0 = val2;
				obj = (object)val2;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.State", (HandleNamedMessageDelegate)obj);
			object obj2 = <>c.<>9__13_1;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					if (FromServer(sender))
					{
						int val11 = default(int);
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref val11, default(ForPrimitives));
						int[] array = new int[Math.Max(0, Math.Min(val11, 64))];
						for (int i = 0; i < array.Length; i++)
						{
							((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref array[i], default(ForPrimitives));
						}
						PaczkomatController.Current?.PlayCourier(array);
					}
				};
				<>c.<>9__13_1 = val3;
				obj2 = (object)val3;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.Courier", (HandleNamedMessageDelegate)obj2);
			object obj3 = <>c.<>9__13_2;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val4 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					if (FromServer(sender))
					{
						int lockerIndex = default(int);
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref lockerIndex, default(ForPrimitives));
						float seconds = default(float);
						((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref seconds, default(ForPrimitives));
						PaczkomatController.Current?.OpenLocker(lockerIndex, seconds);
					}
				};
				<>c.<>9__13_2 = val4;
				obj3 = (object)val4;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.Locker", (HandleNamedMessageDelegate)obj3);
			object obj4 = <>c.<>9__13_3;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val5 = delegate(ulong sender, FastBufferReader reader)
				{
					if (FromServer(sender))
					{
						string template = default(string);
						((FastBufferReader)(ref reader)).ReadValueSafe(ref template, false);
						string code = default(string);
						((FastBufferReader)(ref reader)).ReadValueSafe(ref code, false);
						Manager?.ShowSms(template, code);
					}
				};
				<>c.<>9__13_3 = val5;
				obj4 = (object)val5;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.Sms", (HandleNamedMessageDelegate)obj4);
			object obj5 = <>c.<>9__13_4;
			if (obj5 == null)
			{
				HandleNamedMessageDelegate val6 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_0032: Unknown result type (might be due to invalid IL or missing references)
					//IL_0038: Unknown result type (might be due to invalid IL or missing references)
					if (FromServer(sender))
					{
						bool ok = default(bool);
						((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ok, default(ForPrimitives));
						int orderId = default(int);
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref orderId, default(ForPrimitives));
						byte reason = default(byte);
						((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref reason, default(ForPrimitives));
						Manager?.OnBuyResult(ok, orderId, (FailReason)reason);
					}
				};
				<>c.<>9__13_4 = val6;
				obj5 = (object)val6;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.BuyResult", (HandleNamedMessageDelegate)obj5);
			object obj6 = <>c.<>9__13_5;
			if (obj6 == null)
			{
				HandleNamedMessageDelegate val7 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_0032: Unknown result type (might be due to invalid IL or missing references)
					//IL_0038: Unknown result type (might be due to invalid IL or missing references)
					if (FromServer(sender))
					{
						bool ok = default(bool);
						((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ok, default(ForPrimitives));
						int locker = default(int);
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref locker, default(ForPrimitives));
						byte reason = default(byte);
						((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref reason, default(ForPrimitives));
						Manager?.OnPickupResult(ok, locker, (FailReason)reason);
					}
				};
				<>c.<>9__13_5 = val7;
				obj6 = (object)val7;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.PickupResult", (HandleNamedMessageDelegate)obj6);
			object obj7 = <>c.<>9__13_6;
			if (obj7 == null)
			{
				HandleNamedMessageDelegate val8 = delegate(ulong sender, FastBufferReader reader)
				{
					if (IsServer)
					{
						SendState(sender, Manager);
					}
				};
				<>c.<>9__13_6 = val8;
				obj7 = (object)val8;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.RequestState", (HandleNamedMessageDelegate)obj7);
			object obj8 = <>c.<>9__13_7;
			if (obj8 == null)
			{
				HandleNamedMessageDelegate val9 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004d: Unknown result type (might be due to invalid IL or missing references)
					if (IsServer && !((Object)(object)Manager == (Object)null))
					{
						int num = default(int);
						((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
						if (num >= 0 && num <= 64)
						{
							int[] array = new int[num];
							for (int i = 0; i < num; i++)
							{
								((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref array[i], default(ForPrimitives));
							}
							Manager.ServerBuy(sender, array);
						}
					}
				};
				<>c.<>9__13_7 = val9;
				obj8 = (object)val9;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.Buy", (HandleNamedMessageDelegate)obj8);
			object obj9 = <>c.<>9__13_8;
			if (obj9 == null)
			{
				HandleNamedMessageDelegate val10 = delegate(ulong sender, FastBufferReader reader)
				{
					if (IsServer && (Object)(object)Manager != (Object)null)
					{
						string code = default(string);
						((FastBufferReader)(ref reader)).ReadValueSafe(ref code, false);
						Manager.ServerPickup(sender, code);
					}
				};
				<>c.<>9__13_8 = val10;
				obj9 = (object)val10;
			}
			val.RegisterNamedMessageHandler("miniSpoXster77.UFO_ImPost.Pickup", (HandleNamedMessageDelegate)obj9);
		}

		private static bool FromServer(ulong sender)
		{
			return sender == 0;
		}

		internal static void BroadcastState(ImPostManager manager)
		{
			Broadcast("miniSpoXster77.UFO_ImPost.State", delegate(FastBufferWriter w)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				WriteState(w, manager);
			});
		}

		internal static void SendState(ulong clientId, ImPostManager manager)
		{
			if ((Object)(object)manager != (Object)null)
			{
				Send("miniSpoXster77.UFO_ImPost.State", clientId, delegate(FastBufferWriter w)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					WriteState(w, manager);
				});
			}
		}

		internal static void BroadcastCourier(int[] lockers)
		{
			Broadcast("miniSpoXster77.UFO_ImPost.Courier", delegate(FastBufferWriter w)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: 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_0036: Unknown result type (might be due to invalid IL or missing references)
				int num = lockers.Length;
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				int[] array = lockers;
				for (num = 0; num < array.Length; num++)
				{
					int num2 = array[num];
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
				}
			});
		}

		internal static void BroadcastLockerOpen(int locker, float seconds)
		{
			Broadcast("miniSpoXster77.UFO_ImPost.Locker", delegate(FastBufferWriter w)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref locker, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref seconds, default(ForPrimitives));
			});
		}

		internal static void BroadcastSms(string template, string code)
		{
			Broadcast("miniSpoXster77.UFO_ImPost.Sms", delegate(FastBufferWriter w)
			{
				((FastBufferWriter)(ref w)).WriteValueSafe(template ?? string.Empty, false);
				((FastBufferWriter)(ref w)).WriteValueSafe(code, false);
			});
		}

		internal static void SendBuyResult(ulong clientId, bool ok, int orderId, FailReason reason)
		{
			Send("miniSpoXster77.UFO_ImPost.BuyResult", clientId, delegate(FastBufferWriter w)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref ok, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref orderId, default(ForPrimitives));
				byte b = (byte)reason;
				((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			});
		}

		internal static void SendPickupResult(ulong clientId, bool ok, int locker, FailReason reason)
		{
			Send("miniSpoXster77.UFO_ImPost.PickupResult", clientId, delegate(FastBufferWriter w)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref ok, default(ForPrimitives));
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref locker, default(ForPrimitives));
				byte b = (byte)reason;
				((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			});
		}

		internal static void RequestStateFromServer()
		{
			Send("miniSpoXster77.UFO_ImPost.RequestState", 0uL, delegate
			{
			});
		}

		internal static void SendBuy(int[] items)
		{
			Send("miniSpoXster77.UFO_ImPost.Buy", 0uL, delegate(FastBufferWriter w)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: 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_0036: Unknown result type (might be due to invalid IL or missing references)
				int num = items.Length;
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				int[] array = items;
				for (num = 0; num < array.Length; num++)
				{
					int num2 = array[num];
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
				}
			});
		}

		internal static void SendPickup(string code)
		{
			Send("miniSpoXster77.UFO_ImPost.Pickup", 0uL, delegate(FastBufferWriter w)
			{
				((FastBufferWriter)(ref w)).WriteValueSafe(code, false);
			});
		}

		private static void WriteState(FastBufferWriter writer, ImPostManager manager)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			bool parked = manager.Parked;
			((FastBufferWriter)(ref writer)).WriteValueSafe<bool>(ref parked, default(ForPrimitives));
			Order.WriteList(writer, manager.Orders);
		}

		private static void Broadcast(string name, Action<FastBufferWriter> write)
		{
			if (!IsServer)
			{
				return;
			}
			foreach (ulong connectedClientsId in Net.ConnectedClientsIds)
			{
				if (connectedClientsId != Net.LocalClientId)
				{
					Send(name, connectedClientsId, write);
				}
			}
		}

		private unsafe static void Send(string name, ulong clientId, Action<FastBufferWriter> write)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager net = Net;
			CustomMessagingManager val = ((net != null) ? net.CustomMessagingManager : null);
			if (val == null)
			{
				return;
			}
			FastBufferWriter val2 = default(FastBufferWriter);
			((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, 65536);
			try
			{
				write(val2);
				val.SendNamedMessage(name, clientId, val2, (NetworkDelivery)4);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose();
			}
		}
	}
	internal enum FailReason : byte
	{
		None,
		WrongCode,
		NotReady,
		NotEnoughCredits,
		TooManyItems,
		Invalid
	}
	internal static class L
	{
		private static bool Pl => Plugin.Lang.Value == Language.Polish;

		internal static string HoverOpen => T("Collect parcel", "Odbierz paczkę");

		internal static string ScanName => T("ImPost Parcel Locker", "Paczkomat ImPost");

		internal static string PanelLabel => T("Parcel locker", "Paczkomat");

		internal static string VanSlogan => T("Parcel delivery", "Dostawa paczek");

		internal static string SmsTitle => T("SMS from ImPost", "SMS od ImPost");

		internal static string SmsDefault => T("Your parcel is ready for pickup. Collect it at the nearest ImPost locker with code {code}", "Twoja paczka jest gotowa do odbioru. Odbierz ją w najbliższym automacie ImPost z kodem {code}");

		internal static string PickupTitle => T("Parcel pickup", "Odbiór paczki");

		internal static string PickupHint => T("Enter the pickup code from the ImPost app.", "Wpisz kod odbioru z aplikacji ImPost.");

		internal static string PhoneLabel => T("Phone number", "Numer telefonu");

		internal static string Locked => T("locked", "zablokowane");

		internal static string CodeLabel => T("Pickup code", "Kod odbioru");

		internal static string Cancel => T("Cancel", "Anuluj");

		internal static string Collect => T("Collect parcel", "Odbierz paczkę");

		internal static string EnterFourDigits => T("Enter the 4-digit pickup code.", "Wpisz 4-cyfrowy kod odbioru.");

		internal static string WrongCode => T("Wrong pickup code.", "Nieprawidłowy kod odbioru.");

		internal static string Checking => T("Checking...", "Sprawdzam...");

		internal static string NotReady => T("The locker is not ready yet.", "Paczkomat nie jest jeszcze gotowy.");

		internal static string AppSubtitle => T("Parcels & shop", "Paczki i sklep");

		internal static string TabParcels => T("Parcels", "Paczki");

		internal static string TabShop => T("Shop", "Sklep");

		internal static string NoOrders => T("No parcels yet.\nOrder something in the Shop tab.", "Brak paczek.\nZamów coś w zakładce Sklep.");

		internal static string PickupCodeLabel => T("Pickup code", "Kod odbioru");

		internal static string Credits =