using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: AssemblyTitle("Hats Hats Hats")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyMetadata("Notice", "Copyright (c) casualexpie. All rights reserved. Do NOT decompile, disassemble, or reverse-engineer this assembly. Report bug symptoms on the Nexus Bugs page; do not post decompiled or reconstructed source. Reverse-engineering this DLL is not authorized.")]
[assembly: AssemblyDescription("Adds hats to Casualties: Unknown.")]
[assembly: AssemblyProduct("Hats Hats Hats")]
[assembly: AssemblyCopyright("Copyright (c) casualexpie")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HatsHatsHats;
[BepInPlugin("hatshatshats", "Hats Hats Hats", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public const string Version = "1.0.2";
internal static ManualLogSource Log;
internal static ConfigEntry<bool> SantaOnStart;
internal static ConfigEntry<bool> ConeInLoot;
private void Awake()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
SantaOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Santa Hat", "GiveOnNewRun", true, "Start every new run wearing a Santa hat.");
ConeInLoot = ((BaseUnityPlugin)this).Config.Bind<bool>("Traffic Cone", "FindAndBuy", true, "Traffic cone hats can turn up in loot around the layers and in trader stock.");
Reskin.Bind(((BaseUnityPlugin)this).Config, 2f, 0f, 0f, 1f, -1f, 2f, "hats");
HatResources.Install();
Harmony val = new Harmony("hatshatshats");
val.PatchAll(typeof(Plugin).Assembly);
StartGift.Patch(val);
if (Item.GlobalItems != null && Item.GlobalItems.Count > 0 && !Item.GlobalItems.ContainsKey("trafficconehat"))
{
SetupPatch.Register();
}
GameObject val2 = new GameObject("HatsHeadFit");
Object.DontDestroyOnLoad((Object)(object)val2);
((Object)val2).hideFlags = (HideFlags)61;
val2.AddComponent<HeadFit>();
Log.LogInfo((object)"Hats Hats Hats 1.0.2 loaded.");
}
}
internal class HatDef
{
public string Id;
public string Name;
public string Desc;
public string[] Art;
public Dictionary<char, Color32> Colors;
public int PivotX;
public int PivotY;
public int Value;
public float Armor;
public float HitLoss;
public float Isolation;
public float Weight;
public int VisualOffset;
public Sprite Main;
public Sprite Milky;
public Rect Bounds;
}
internal static class Hats
{
public const string Cone = "trafficconehat";
public const string Santa = "holidayhat";
public static readonly List<HatDef> All;
private static readonly Dictionary<string, HatDef> byId;
private static readonly Dictionary<string, GameObject> templates;
private static GameObject holder;
static Hats()
{
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: 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_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
All = new List<HatDef>();
byId = new Dictionary<string, HatDef>(StringComparer.OrdinalIgnoreCase);
templates = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase);
HatDef hatDef = new HatDef();
hatDef.Id = "trafficconehat";
hatDef.Name = "Traffic Cone";
hatDef.Desc = "A traffic cone. Worn on the head, it says \"caution\" louder than any words could.";
hatDef.Art = new string[24]
{
"......................", "......................", "..........DL..........", ".........DOL..........", ".........DOL..........", ".........SWW..........", "........SSWWW.........", "........DOOOL.........", ".......DDOOOLL........", ".......SSWWWWW........",
"......SSWWWWWWW.......", "......DDOOOOOOL.......", ".....DDOOOOOOOLL......", "..BGGGGGGGGGGGGGGGG...", "..BBBBBBBBBBBBBBBBB...", "......................", "......................", "......................", "......................", "......................",
"......................", "......................", "......................", "......................"
};
hatDef.Colors = new Dictionary<char, Color32>();
hatDef.Colors['O'] = Hex("F47A20");
hatDef.Colors['L'] = Hex("FF9E4A");
hatDef.Colors['D'] = Hex("C9561A");
hatDef.Colors['W'] = Hex("F2F2F2");
hatDef.Colors['S'] = Hex("BEBEC8");
hatDef.Colors['G'] = Hex("4A4A52");
hatDef.Colors['B'] = Hex("26262B");
hatDef.PivotX = 11;
hatDef.PivotY = 9;
hatDef.Value = 6;
hatDef.Armor = 0.4f;
hatDef.HitLoss = 0.5f;
hatDef.Isolation = 0.02f;
hatDef.Weight = 0.4f;
hatDef.VisualOffset = 8;
Add(hatDef);
}
private static void Add(HatDef d)
{
All.Add(d);
byId[d.Id] = d;
}
private static Color32 Hex(string h)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
return new Color32(Convert.ToByte(h.Substring(0, 2), 16), Convert.ToByte(h.Substring(2, 2), 16), Convert.ToByte(h.Substring(4, 2), 16), byte.MaxValue);
}
public static HatDef Get(string id)
{
if (id == null || !byId.TryGetValue(id, out var value))
{
return null;
}
return value;
}
public static string NameOf(string key)
{
if (key == null)
{
return null;
}
bool flag = key.EndsWith("dsc", StringComparison.Ordinal);
string text = (flag ? key.Substring(0, key.Length - 3) : key);
if (!flag && string.Equals(text, "holidayhat", StringComparison.OrdinalIgnoreCase))
{
return "Santa Hat";
}
HatDef hatDef = Get(text);
if (hatDef == null)
{
return null;
}
if (!flag)
{
return hatDef.Name;
}
return hatDef.Desc;
}
public static ItemInfo NewInfo(HatDef d)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
ItemInfo val = new ItemInfo();
val.category = "utility";
val.slotRotation = 0f;
val.usable = false;
val.usableOnLimb = false;
val.destroyAtZeroCondition = true;
val.wearable = true;
val.desiredWearLimb = "Head";
val.wearSlotId = "hat";
val.wearableArmor = d.Armor;
val.wearableHitDurabilityLossMultiplier = d.HitLoss;
val.wearableIsolation = d.Isolation;
val.wearableVisualOffset = d.VisualOffset;
val.weight = d.Weight;
val.value = d.Value;
val.rec = new Recognition(0);
ItemInfo val2 = val;
try
{
val2.SetTags();
}
catch (Exception)
{
}
return val2;
}
private static void MakeSprites(HatDef d)
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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)
if ((Object)(object)d.Main != (Object)null)
{
return;
}
int num = d.Art.Length;
int length = d.Art[0].Length;
Color32[] array = (Color32[])(object)new Color32[length * num];
int num2 = length;
int num3 = -1;
int num4 = num;
int num5 = -1;
for (int i = 0; i < num; i++)
{
string text = d.Art[i];
int num6 = num - 1 - i;
for (int j = 0; j < length; j++)
{
if (j < text.Length && d.Colors.TryGetValue(text[j], out var value))
{
array[num6 * length + j] = value;
if (j < num2)
{
num2 = j;
}
if (j > num3)
{
num3 = j;
}
if (num6 < num4)
{
num4 = num6;
}
if (num6 > num5)
{
num5 = num6;
}
}
else
{
ref Color32 reference = ref array[num6 * length + j];
reference = new Color32((byte)0, (byte)0, (byte)0, (byte)0);
}
}
}
Texture2D val = new Texture2D(length, num, (TextureFormat)4, false);
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
val.SetPixels32(array);
val.Apply();
((Object)val).name = d.Id;
((Object)val).hideFlags = (HideFlags)61;
d.Main = Sprite.Create(val, new Rect(0f, 0f, (float)length, (float)num), new Vector2((float)d.PivotX / (float)length, (float)d.PivotY / (float)num), 8f, 0u, (SpriteMeshType)0);
((Object)d.Main).name = d.Id;
((Object)d.Main).hideFlags = (HideFlags)61;
d.Milky = Sprite.Create(val, new Rect(0f, 0f, (float)length, (float)num), new Vector2((float)(d.PivotX - 1) / (float)length, (float)(d.PivotY - 1) / (float)num), 8f, 0u, (SpriteMeshType)0);
((Object)d.Milky).name = d.Id + "milky";
((Object)d.Milky).hideFlags = (HideFlags)61;
if (num3 < 0)
{
d.Bounds = new Rect(0f, 0f, 1f, 1f);
}
else
{
d.Bounds = new Rect((float)(num2 - d.PivotX), (float)(num4 - d.PivotY), (float)(num3 - num2 + 1), (float)(num5 - num4 + 1));
}
}
public static Object Template(string path)
{
HatDef hatDef = Get(path);
if (hatDef == null)
{
return null;
}
if (templates.TryGetValue(hatDef.Id, out var value) && (Object)(object)value != (Object)null)
{
return (Object)(object)value;
}
value = Build(hatDef);
if ((Object)(object)value != (Object)null)
{
templates[hatDef.Id] = value;
}
return (Object)(object)value;
}
private static GameObject Build(HatDef d)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0144: 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)
GameObject val = Resources.Load<GameObject>("holidayhat");
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogError((object)("Couldn't find the game's holiday hat to base the " + d.Name + " on."));
return null;
}
MakeSprites(d);
if ((Object)(object)holder == (Object)null)
{
holder = new GameObject("HatsHatsHatsTemplates");
holder.SetActive(false);
((Object)holder).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)holder);
}
GameObject val2 = Object.Instantiate<GameObject>(val, holder.transform);
((Object)val2).name = d.Id;
Item component = val2.GetComponent<Item>();
component.id = d.Id;
SpriteRenderer component2 = val2.GetComponent<SpriteRenderer>();
component2.sprite = d.Main;
WearableSpriteSwap val3 = val2.GetComponent<WearableSpriteSwap>();
if ((Object)(object)val3 == (Object)null)
{
val3 = val2.AddComponent<WearableSpriteSwap>();
}
val3.sprites = new List<Sprite> { d.Main, d.Milky };
val3.customScale = new List<float>();
BoxCollider2D component3 = val2.GetComponent<BoxCollider2D>();
if ((Object)(object)component3 != (Object)null)
{
component3.size = new Vector2(((Rect)(ref d.Bounds)).width / 8f, ((Rect)(ref d.Bounds)).height / 8f);
((Collider2D)component3).offset = new Vector2((((Rect)(ref d.Bounds)).x + ((Rect)(ref d.Bounds)).width * 0.5f) / 8f, (((Rect)(ref d.Bounds)).y + ((Rect)(ref d.Bounds)).height * 0.5f) / 8f);
}
return val2;
}
}
internal static class Reskin
{
internal static ConfigEntry<float> ExpieX;
internal static ConfigEntry<float> ExpieY;
internal static ConfigEntry<float> MilkyX;
internal static ConfigEntry<float> MilkyY;
internal static ConfigEntry<float> DuneX;
internal static ConfigEntry<float> DuneY;
internal static ConfigEntry<bool> Fit;
private static BaseUnityPlugin plugin;
private static bool looked;
private static bool hasDune;
public static void Bind(ConfigFile c, float ex, float ey, float mx, float my, float dx, float dy, string what)
{
DuneX = c.Bind<float>("Interpretation", "DuneX", dx, "With the Interpretation reskin (v1.2.0 or newer): move " + what + " on Dune forward (+) or back (-), in pixels.");
DuneY = c.Bind<float>("Interpretation", "DuneY", dy, "With the Interpretation reskin (v1.2.0 or newer): move " + what + " on Dune up (+) or down (-), in pixels.");
Fit = c.Bind<bool>("Interpretation", "FitToReskin", true, "Fit " + what + " to the Interpretation reskin. Only does something when the Interpretation mod is installed. Also on the pause screen.");
ExpieX = c.Bind<float>("Interpretation", "ExpieX", ex, "With the Interpretation reskin: move " + what + " on Expie forward (+) or back (-), in pixels.");
ExpieY = c.Bind<float>("Interpretation", "ExpieY", ey, "With the Interpretation reskin: move " + what + " on Expie up (+) or down (-), in pixels.");
MilkyX = c.Bind<float>("Interpretation", "MilkyX", mx, "With the Interpretation reskin: move " + what + " on Milky forward (+) or back (-), in pixels.");
MilkyY = c.Bind<float>("Interpretation", "MilkyY", my, "With the Interpretation reskin: move " + what + " on Milky up (+) or down (-), in pixels.");
}
public static bool On(int chr)
{
if (chr < 0 || chr > 2)
{
return false;
}
if (!looked)
{
looked = true;
if (Chainloader.PluginInfos.TryGetValue("interpretation", out var value) && value != null)
{
plugin = value.Instance;
hasDune = value.Metadata != null && value.Metadata.Version >= new Version(1, 2, 0);
}
}
if ((Object)(object)plugin == (Object)null || (chr == 2 && !hasDune))
{
return false;
}
if (Flag("General", "Enabled"))
{
return Flag("Characters", chr switch
{
1 => "Milky",
0 => "Expie",
_ => "Dune",
});
}
return false;
}
private static bool Flag(string section, string key)
{
ConfigEntry<bool> val = default(ConfigEntry<bool>);
if (plugin.Config.TryGetEntry<bool>(section, key, ref val))
{
return val.Value;
}
return true;
}
public static Vector2 Pixels(int chr)
{
//IL_0014: 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_004f: 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)
if (!Fit.Value || !On(chr))
{
return Vector2.zero;
}
return (Vector2)(chr switch
{
1 => new Vector2(MilkyX.Value, MilkyY.Value),
0 => new Vector2(ExpieX.Value, ExpieY.Value),
_ => new Vector2(DuneX.Value, DuneY.Value),
});
}
}
internal class HeadFit : MonoBehaviour
{
private float wait;
private void Update()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_00bd: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
wait -= Time.unscaledDeltaTime;
if (wait > 0f)
{
return;
}
wait = 0.5f;
try
{
Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Limb val2 = val.LimbByName("Head");
if ((Object)(object)val2 == (Object)null)
{
return;
}
Vector2 val3 = Reskin.Pixels(val.charType);
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(val3.x / 8f, val3.y / 8f, 0f);
foreach (Transform item in ((Component)val2).transform)
{
Transform val5 = item;
Item component = ((Component)val5).GetComponent<Item>();
if (!((Object)(object)component == (Object)null) && component.Stats.wearable && !(component.Stats.desiredWearLimb != "Head"))
{
Vector3 val6 = val5.localPosition - val4;
if (((Vector3)(ref val6)).sqrMagnitude > 0.0001f)
{
val5.localPosition = val4;
}
}
}
}
catch (Exception)
{
}
}
}
[HarmonyPatch(typeof(Body), "WearWearable")]
internal static class HeadFitPatch
{
private static void Postfix(Body __instance, Item item)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0083: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)item == (Object)null || (Object)(object)__instance == (Object)null)
{
return;
}
Limb val = __instance.LimbByName("Head");
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)item).transform.parent != (Object)(object)((Component)val).transform))
{
Vector2 val2 = Reskin.Pixels(__instance.charType);
if (!(val2 == Vector2.zero))
{
((Component)item).transform.localPosition = new Vector3(val2.x / 8f, val2.y / 8f, 0f);
}
}
}
catch (Exception)
{
}
}
}
internal class HatResources : ResourcesAPI
{
private static ResourcesAPI previous;
private static readonly MethodInfo LoadMethod = AccessTools.Method(typeof(ResourcesAPI), "Load", new Type[2]
{
typeof(string),
typeof(Type)
}, (Type[])null);
public static void Install()
{
previous = ResourcesAPI.overrideAPI;
ResourcesAPI.overrideAPI = (ResourcesAPI)(object)new HatResources();
}
protected override Object Load(string path, Type systemTypeInstance)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
if (Hats.Get(path) != null && (systemTypeInstance == null || systemTypeInstance.IsAssignableFrom(typeof(GameObject))))
{
try
{
Object val = Hats.Template(path);
if (val != (Object)null)
{
return val;
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Couldn't create the hat " + path + ": " + ex));
}
}
if (previous != null && LoadMethod != null)
{
return (Object)LoadMethod.Invoke(previous, new object[2] { path, systemTypeInstance });
}
return ((ResourcesAPI)this).Load(path, systemTypeInstance);
}
}
[HarmonyPatch(typeof(Item), "SetupItems")]
internal static class SetupPatch
{
private static void Postfix()
{
Register();
}
internal static void Register()
{
try
{
List<string> value = null;
if (ItemLootPool.pool != null)
{
ItemLootPool.pool.TryGetValue("utility", out value);
}
foreach (HatDef item in Hats.All)
{
ItemInfo val = Hats.NewInfo(item);
val.fullName = item.Name;
val.description = item.Desc;
Item.GlobalItems[item.Id] = val;
if (value == null)
{
continue;
}
if (Plugin.ConeInLoot.Value)
{
if (!value.Contains(item.Id))
{
value.Add(item.Id);
}
}
else
{
value.Remove(item.Id);
}
}
Plugin.Log.LogInfo((object)("Added " + Hats.All.Count + " hat(s) to the game."));
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Couldn't add the hats: " + ex));
}
}
}
[HarmonyPatch(typeof(Locale), "GetItem")]
internal static class NamePatch
{
private static bool Prefix(string str, ref string __result)
{
string text = Hats.NameOf(str);
if (text == null)
{
return true;
}
__result = text;
return false;
}
}
[HarmonyPatch(typeof(ConsoleScript), "RegisterSpawnEntities")]
internal static class ConsoleListPatch
{
private static void Postfix(ConsoleScript __instance)
{
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(ConsoleScript), "SearchExact", (Type[])null, (Type[])null);
object obj = ((methodInfo != null) ? methodInfo.Invoke(methodInfo.IsStatic ? null : __instance, new object[1] { "spawn" }) : null);
if (obj == null)
{
return;
}
FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), "argAutofill");
IDictionary dictionary = ((fieldInfo != null) ? (fieldInfo.GetValue(obj) as IDictionary) : null);
if (dictionary == null || !dictionary.Contains(0) || !(dictionary[0] is List<string> list))
{
return;
}
foreach (HatDef item in Hats.All)
{
if (!list.Contains(item.Id))
{
list.Add(item.Id);
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Couldn't add the hats to the console spawn list: " + ex.Message));
}
}
}
internal static class StartGift
{
public static void Patch(Harmony h)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(WorldGeneration), "WorldPlacePlayer", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = ((methodInfo != null) ? AccessTools.EnumeratorMoveNext((MethodBase)methodInfo) : null);
if (methodInfo2 == null)
{
Plugin.Log.LogWarning((object)"Couldn't find where the game places the player, so there's no Santa hat at the start of a run.");
}
else
{
h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(StartGift).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Couldn't hook the start of a run: " + ex.Message));
}
}
private static void Postfix(bool __result)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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)
if (__result || !Plugin.SantaOnStart.Value)
{
return;
}
try
{
WorldGeneration world = WorldGeneration.world;
if ((Object)(object)world == (Object)null || world.biomeDepth != 0 || (int)world.biomeOverride != 0)
{
return;
}
Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
if (!((Object)(object)val == (Object)null))
{
GameObject val2 = Utils.Create("holidayhat", Vector2.op_Implicit(((Component)val).transform.position), 0f);
Item val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Item>() : null);
if (!((Object)(object)val3 == (Object)null))
{
val.AutoPickUpItem(val3);
Plugin.Log.LogInfo((object)(val.HasWearable(val3) ? "Santa hat on." : "Santa hat given (the hat slot was taken)."));
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Couldn't hand out the Santa hat: " + ex.Message));
}
}
}