using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using ChatCommandAPI;
using ChatCommandAPI.Utils;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.BindingPathEnums;
using LethalSprayPaintColor.Commands;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("baer1.SprayPaintColor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7e6ebb4ec8b93483ed65f06a3ec22d4289ab13bf")]
[assembly: AssemblyProduct("LethalSprayPaintColor")]
[assembly: AssemblyTitle("baer1.SprayPaintColor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 LethalSprayPaintColor
{
public class KeybindManager : LcInputActions
{
internal KeybindManager()
{
foreach (SprayPaintColor.CommonColors i in Enum.GetValues(typeof(SprayPaintColor.CommonColors)))
{
((LcInputActions)this).Asset[string.Format("{0}{1}", "SprayPaintColor", i)].performed += delegate(CallbackContext ctx)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
ChangeSprayColorKeybind(ctx, i);
};
}
}
public override void CreateInputActions(in InputActionMapBuilder builder)
{
foreach (SprayPaintColor.CommonColors value in Enum.GetValues(typeof(SprayPaintColor.CommonColors)))
{
builder.NewActionBinding().WithActionId(string.Format("{0}{1}", "SprayPaintColor", value)).WithActionType((InputActionType)1)
.WithKeyboardControl((KeyboardControl)0)
.WithBindingName($"Change spray color to {value}")
.Finish();
}
}
private static void ChangeSprayColorKeybind(CallbackContext ctx, SprayPaintColor.CommonColors i)
{
PlayerControllerB localPlayerController;
if (((CallbackContext)(ref ctx)).performed && Object.op_Implicit((Object)(object)(localPlayerController = GameNetworkManager.Instance.localPlayerController)) && !localPlayerController.quickMenuManager.isMenuOpen && !localPlayerController.inTerminalMenu && !localPlayerController.isTypingChat)
{
GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
SprayPaintItem val = (SprayPaintItem)(object)((currentlyHeldObjectServer is SprayPaintItem) ? currentlyHeldObjectServer : null);
if (val != null && !val.isWeedKillerSprayBottle)
{
SprayPaintColor.RequestColorServerRpc(val, (uint)i);
HUDManager.Instance.DisplayTip("SprayPaintColor", $"Requested color change to {i}", false, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip("SprayPaintColor", "You're not holding a spray can", true, false, "LC_Tip1");
}
}
}
}
[BepInPlugin("baer1.SprayPaintColor", "LethalSprayPaintColor", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SprayPaintColor : BaseUnityPlugin
{
public enum CommonColors : uint
{
Red = 16711680u,
Blue = 255u,
Cyan = 65535u,
Green = 65280u,
Yellow = 16776960u,
Pink = 16758465u,
Purple = 9055202u,
Orange = 16747520u,
Gold = 16766720u,
Indigo = 4915330u,
Magenta = 16711935u,
Brown = 9127187u,
Crimson = 14423100u,
Chartreuse = 8388352u,
Coral = 16744272u,
Goldenrod = 14329120u,
Maroon = 8388608u,
Navy = 128u,
Olive = 8421376u,
Orchid = 14315734u,
Violet = 15631086u,
DarkBlue = 139u,
DarkGreen = 25600u,
DarkRed = 9109504u,
MediumBlue = 205u,
MediumPurple = 9662683u,
LightPink = 16761035u,
LightBlue = 11393254u,
HotPink = 16738740u,
DeepPink = 16716947u,
SkyBlue = 8900331u,
DeepSkyBlue = 49151u,
CornflowerBlue = 6591981u,
LawnGreen = 8190976u,
GreenYellow = 11403055u,
OrangeRed = 16729344u,
Silver = 12632256u,
White = 16777215u,
Gray = 8421504u,
Black = 0u
}
[CompilerGenerated]
private static class <>O
{
public static RpcReceiveHandler <0>____rpc_handler_RequestColorServerRpc;
public static RpcReceiveHandler <1>____rpc_handler_SetColorClientRpc;
}
internal static Harmony Harmony = null;
private const uint REQUEST_COLOR_SERVER_RPC = 1788770031u;
private const uint SET_COLOR_CLIENT_RPC = 1788770032u;
private static readonly Dictionary SprayCanMaterials = new Dictionary();
private static readonly Dictionary ParticleMaterials = new Dictionary();
public static SprayPaintColor Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Harmony = new Harmony("baer1.SprayPaintColor");
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll(typeof(SprayPaintColor));
Logger.LogDebug((object)"Finished patching!");
if (Chainloader.PluginInfos.ContainsKey("baer1.ChatCommandAPI"))
{
registerChatCommand();
}
if (Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils"))
{
registerInputActions();
}
Logger.LogInfo((object)"baer1.SprayPaintColor v1.0.0 has loaded!");
[MethodImpl(MethodImplOptions.NoInlining)]
static void registerChatCommand()
{
new LethalSprayPaintColor.Commands.SprayPaintColor();
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void registerInputActions()
{
new KeybindManager();
}
}
[HarmonyPatch(typeof(SprayPaintItem), "__initializeRpcs")]
[HarmonyPostfix]
private static void SprayPaintItem___initializeRpcs(ref SprayPaintItem __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0043: 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: Expected O, but got Unknown
SprayPaintItem obj = __instance;
object obj2 = <>O.<0>____rpc_handler_RequestColorServerRpc;
if (obj2 == null)
{
RpcReceiveHandler val = __rpc_handler_RequestColorServerRpc;
<>O.<0>____rpc_handler_RequestColorServerRpc = val;
obj2 = (object)val;
}
((NetworkBehaviour)obj).__registerRpc(1788770031u, (RpcReceiveHandler)obj2, "RequestColorServerRpc");
SprayPaintItem obj3 = __instance;
object obj4 = <>O.<1>____rpc_handler_SetColorClientRpc;
if (obj4 == null)
{
RpcReceiveHandler val2 = __rpc_handler_SetColorClientRpc;
<>O.<1>____rpc_handler_SetColorClientRpc = val2;
obj4 = (object)val2;
}
((NetworkBehaviour)obj3).__registerRpc(1788770032u, (RpcReceiveHandler)obj4, "SetColorClientRpc");
}
private static void __rpc_handler_RequestColorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_003e: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
uint argb = default(uint);
((FastBufferReader)(ref reader)).ReadValueSafe(ref argb, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
RequestColorServerRpc((SprayPaintItem)target, argb);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_SetColorClientRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_003e: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
uint argb = default(uint);
((FastBufferReader)(ref reader)).ReadValueSafe(ref argb, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
SetColorClientRpc((SprayPaintItem)target, argb);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[ServerRpc(RequireOwnership = true)]
internal static void RequestColorServerRpc(SprayPaintItem __instance, uint argb)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0062: 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)
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)__instance).__beginSendServerRpc(1788770031u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref argb, default(ForPrimitives));
((NetworkBehaviour)__instance).__endSendServerRpc(ref val2, 1788770031u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1 && (networkManager == null || networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)__instance).__rpc_exec_stage = (__RpcExecStage)0;
SetColorClientRpc(__instance, argb);
}
}
}
[ClientRpc]
private static void SetColorClientRpc(SprayPaintItem __instance, uint argb)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0062: 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)
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)__instance).__beginSendClientRpc(1788770032u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref argb, default(ForPrimitives));
((NetworkBehaviour)__instance).__endSendClientRpc(ref val2, 1788770032u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1 && (networkManager == null || networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)__instance).__rpc_exec_stage = (__RpcExecStage)0;
__instance.sprayCanMatsIndex = GetMatIndex(argb);
}
}
}
internal static int GetMatIndex(uint argb)
{
return (int)argb | -16777216;
}
internal static bool TryGetColor(int matIndex, out uint argb)
{
if (matIndex >= 0)
{
argb = 0u;
return false;
}
argb = (uint)(matIndex | -16777216);
return true;
}
[HarmonyPatch(typeof(SprayPaintItem), "AddSprayPaintLocal")]
[HarmonyTranspiler]
private static IEnumerable SprayPaintItem_AddSprayPaintLocal(IEnumerable instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
while (true)
{
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SprayPaintItem), "sprayCanMats"), (string)null)
});
if (val.IsInvalid)
{
break;
}
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null)
});
if (val.IsInvalid)
{
break;
}
val.SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SprayPaintColor), "GetItemReplacement", (Type[])null, (Type[])null)));
}
return val.InstructionEnumeration();
}
private static Color32 UnityColor(uint argb)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
return new Color32((byte)((argb & 0xFF0000) >> 16), (byte)((argb & 0xFF00) >> 8), (byte)(argb & 0xFF), byte.MaxValue);
}
private static Material GetItemReplacement(Material[] sprayCanMats, int sprayCanMatsIndex)
{
//IL_0031: 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)
//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_004e: Expected O, but got Unknown
if (!TryGetColor(sprayCanMatsIndex, out var argb))
{
return sprayCanMats[sprayCanMatsIndex];
}
if (SprayCanMaterials.TryGetValue(argb, out Material value) && (Object)(object)value != (Object)null)
{
return value;
}
Dictionary sprayCanMaterials = SprayCanMaterials;
uint key = argb;
Material val = new Material(sprayCanMats[0])
{
color = Color32.op_Implicit(UnityColor(argb))
};
Material result = val;
sprayCanMaterials[key] = val;
return result;
}
[HarmonyPatch(typeof(SprayPaintItem), "StartSpraying")]
[HarmonyPatch(typeof(SprayPaintItem), "PlayCanEmptyEffect")]
[HarmonyPrefix]
private static void SprayPaintItem_StartSpraying(ref SprayPaintItem __instance)
{
Material particleMaterial = GetParticleMaterial(__instance.particleMats, __instance.sprayCanMatsIndex);
((Renderer)((Component)__instance.sprayParticle).GetComponent()).material = particleMaterial;
((Renderer)((Component)__instance.sprayCanNeedsShakingParticle).GetComponent()).material = particleMaterial;
}
private static Material GetParticleMaterial(Material[] particleMats, int sprayCanMatsIndex)
{
//IL_0031: 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)
//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_004e: Expected O, but got Unknown
if (!TryGetColor(sprayCanMatsIndex, out var argb))
{
return particleMats[sprayCanMatsIndex];
}
if (ParticleMaterials.TryGetValue(argb, out Material value) && (Object)(object)value != (Object)null)
{
return value;
}
Dictionary particleMaterials = ParticleMaterials;
uint key = argb;
Material val = new Material(particleMats[0])
{
color = Color32.op_Implicit(UnityColor(argb))
};
Material result = val;
particleMaterials[key] = val;
return result;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "baer1.SprayPaintColor";
public const string PLUGIN_NAME = "LethalSprayPaintColor";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LethalSprayPaintColor.Commands
{
public class SprayPaintColor : Command
{
private static readonly Regex HexCode = new Regex("^(?:(?:#|0x)?([0-9A-F]{6})|([0-9A-F]{3}))$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public override string Command => "spray";
public override string Description => "Changes the color of your held spray can";
public override string[] Syntax => new string[1] { "" };
public override void Invoke(string args)
{
//IL_001d: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
string[] array = Args.Parse(args, (uint?)null, true).ToArray();
if (array.Length != 1)
{
throw new InvalidArgumentsException();
}
string text = array[0].Trim();
Match match = HexCode.Match(text);
uint num;
if (match.Success)
{
num = uint.Parse(match.Groups[1].Success ? match.Groups[1].Value : string.Concat(match.Groups[2].Value.Select((char i) => $"{i}{i}")), NumberStyles.HexNumber);
}
else
{
if (!Enum.TryParse(typeof(LethalSprayPaintColor.SprayPaintColor.CommonColors), text, ignoreCase: true, out object result))
{
throw new InvalidArgumentsException();
}
num = (uint)result;
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
SprayPaintItem val = (SprayPaintItem)(object)((currentlyHeldObjectServer is SprayPaintItem) ? currentlyHeldObjectServer : null);
if (val == null || val.isWeedKillerSprayBottle)
{
throw new CommandException("You're not holding a spray can");
}
LethalSprayPaintColor.SprayPaintColor.RequestColorServerRpc(val, num);
Chat.Print($"Requested color change to #{num:X6}", (Color?)null);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}