Decompiled source of Vittles v1.0.64

Vittles.dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DixiecaptShared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SailwindProvisions;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using cakeslice;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.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 DixiecaptShared
{
	internal static class TextureLook
	{
		private sealed class Pick
		{
			public string key;

			public string mode;

			public string mat;

			public string tex;

			public string layer;

			public int w;

			public int h;

			public bool hasUv;

			public Rect uv;

			public float tile;

			public bool hasFlat;

			public Color flat;

			public bool fromOurs;

			public bool card;

			public bool turned;
		}

		private sealed class Row
		{
			public string id;

			public string pick;

			public string kind;

			public bool hasOurs;

			public Color ours;
		}

		private sealed class Job
		{
			public Renderer r;

			public int slot;

			public Material m;

			public string id;
		}

		private sealed class Done
		{
			public Material m;

			public Material snap;
		}

		private sealed class Swap
		{
			public Renderer r;

			public int slot;

			public Material was;

			public Material now;
		}

		private sealed class LayerWas
		{
			public Object layer;

			public Texture tex;

			public Vector2 tile;
		}

		internal const string Section = "Look";

		internal const string Key = "Texture look";

		internal const string Detailed = "Detailed";

		internal const string Plain = "Plain";

		internal const string Stock = "Stock Sailwind";

		private static Dictionary<string, Pick> _picks;

		private static Dictionary<string, Row> _rows;

		private static Dictionary<string, string> _sigs;

		private static readonly string Scope = ScopeOf(typeof(TextureLook).Assembly.GetName().Name);

		private static ConfigEntry<string> _cfg;

		private static Action<string> _log;

		private static string _who = "";

		private static bool _perPart;

		private static bool _started;

		private static readonly Dictionary<int, string> _texIds = new Dictionary<int, string>();

		private static readonly Dictionary<int, string> _matIds = new Dictionary<int, string>();

		private static readonly List<Transform> _kept = new List<Transform>();

		private static readonly HashSet<string> _saidKept = new HashSet<string>();

		private static string _applied = "Detailed";

		private static float _scanAt = 2f;

		private static float _scanAgainAt = -1f;

		private static float _nextRound;

		private static float _playingSince = -1f;

		private static readonly Queue<Job> _queue = new Queue<Job>();

		private static readonly HashSet<int> _queued = new HashSet<int>();

		private static int _changed;

		private static int _parts;

		private static bool _saidRound;

		private static readonly Dictionary<int, Done> _done = new Dictionary<int, Done>();

		private static readonly List<Swap> _swaps = new List<Swap>();

		private static readonly Dictionary<int, Material> _copies = new Dictionary<int, Material>();

		private static readonly HashSet<int> _copyIds = new HashSet<int>();

		private static readonly HashSet<int> _notOurs = new HashSet<int>();

		private static readonly HashSet<int> _leftAlone = new HashSet<int>();

		private static readonly HashSet<string> _warned = new HashSet<string>();

		private static readonly Dictionary<int, float> _mPerUv = new Dictionary<int, float>();

		private static Dictionary<string, List<Material>> _gameMats;

		private static float _gameMatsAt = -100f;

		private static readonly Dictionary<string, Material> _matOf = new Dictionary<string, Material>();

		private static readonly Dictionary<string, Texture> _texOf = new Dictionary<string, Texture>();

		private static Type _layerType;

		private static PropertyInfo _layerDiffuse;

		private static PropertyInfo _layerTile;

		private static bool _layerTried;

		private static readonly Dictionary<int, Texture2D> _plain = new Dictionary<int, Texture2D>();

		private static readonly List<LayerWas> _layers = new List<LayerWas>();

		private static readonly HashSet<int> _layerSeen = new HashSet<int>();

		internal static readonly string[] PickTable = new string[50]
		{
			"boards_aestrin|atlas_cut|buildings_M_paint|buildings M paint Diffuse Color|8192|8192||0.523 0.678 0.075 0.117|1.2|0.455 0.337 0.306 1|0|0|0", "boards_emerald|atlas_cut|buildings_E_paint|buildings E paint Diffuse Color|8192|8192||0.69 0.402 0.084 0.261|2.4|0.345 0.212 0.2 1|0|0|0", "boards_plain|atlas_cut|Z planks|junk large_Z planks_Albedo|4096|4096||0.012 0.015 0.256 0.4|2|0.384 0.259 0.188 1|0|0|1", "plaster_aestrin|atlas_cut|buildings_M_paint|buildings M paint Diffuse Color|8192|8192||0.74 0.65 0.09 0.105|3|0.627 0.533 0.475 1|0|0|0", "plaster_alankh|atlas_cut|buildings_A_paint|buildings A paint Diffuse Color|8192|8192||0.012 0.297 0.062 0.051|3|0.839 0.682 0.561 1|0|0|0", "roof_aestrin|atlas_cut|buildings_M_paint|buildings M paint Diffuse Color|8192|8192||0.015 0.015 0.11 0.195|4|0.525 0.239 0.196 1|0|0|0", "roof_emerald|atlas_cut|buildings_E_paint|buildings E paint Diffuse Color|8192|8192||0.557 0.207 0.06 0.143|2|0.412 0.243 0.235 1|0|0|0", "thatch|atlas_cut|buildings_E_paint|buildings E paint Diffuse Color|8192|8192||0.005 0.357 0.076 0.148|2|0.404 0.286 0.255 1|0|0|0", "stone_aestrin|atlas_cut|buildings_M_paint|buildings M paint Diffuse Color|8192|8192||0.14 0.602 0.116 0.119|2|0.561 0.478 0.431 1|0|0|0", "stone_dressed|material_copy|cobblestone|island cave church town_cobblestone_Albedo|4096|4096|||4|0.539 0.5 0.443 1|0|0|0",
			"stone_rough|material_copy|cliffrock|island cave church town_cliffrock_Albedo|4096|4096|||8|0.615 0.577 0.493 1|0|0|0", "stone_blocks_grey|material_copy|metal chronos roof|diffuse|1024|1024|||2|0.379 0.373 0.362 1|0|0|0", "rock|texture||hp_01|256|256|Rock 2||12|0.578 0.557 0.509 1|0|0|0", "brick_red|texture||Brick_05|512|512|Cobblestone Chaotic Red||3|0.695 0.49 0.394 1|0|0|0", "paving_grey|texture||Brick_03|256|256|Cobblestone Grid||3|0.539 0.526 0.492 1|0|0|0", "beam|flat_material|wood2||0|0|||0|0.34 0.258 0.235 1|0|0|0", "wood_light|flat_material|wood3||0|0|||0|0.623 0.485 0.397 1|0|0|0", "wood_warm|flat_material|wood1||0|0|||0|0.424 0.285 0.23 1|0|0|0", "bark|material_copy|tree wood tex|Tree Leaves 1 edited|512|512|||1.5|0.586 0.581 0.491 1|0|0|0", "bark_palm|material_copy|palm tree bark|palm_bark|128|256|||1|0.502 0.448 0.378 1|0|0|0",
			"canvas|material_copy|sail cloth test|ParticleCloudWhite|256|256|||2|1 1 1 1|1|0|0", "rope|material_copy|rope|QPHiResRope.bmp1494e1a0-4267-48de-a564-e98d9d71b959Original|256|256|||0.3|0.676 0.637 0.592 1|0|0|0", "rope_flat|flat_material|rope static||0|0|||0|0.406 0.36 0.331 1|0|0|0", "iron|flat_material|metal2||0|0|||0|0.11 0.145 0.151 1|0|0|0", "brass|flat_material|metal gold||0|0|||0|0.736 0.557 0.198 1|0|0|0", "tin|flat_material|metal3 (anchor)||0|0|||0|0.608 0.693 0.737 1|0|0|0", "soot|flat_material|wood4||0|0|||0|0.094 0.085 0.079 1|0|0|0", "terracotta|flat_material|Material_001||0|0|||0|0.615 0.312 0.256 1|0|0|0", "soil|texture||Dirt_01|256|256|Dirt||6|0.402 0.338 0.246 1|0|0|0", "field|texture||Dirt_03|256|256|Field 2||6|0.415 0.347 0.248 1|0|0|0",
			"mulch|texture||Dirt_04|256|256|Grass Brown||6|0.409 0.337 0.233 1|0|0|0", "path|texture||Dirt_02|256|256|Sand Path||6|0.404 0.346 0.236 1|0|0|0", "sand|texture||hp_earth_ground light|256|256|Sand Rocky||6|0.809 0.702 0.577 1|0|0|0", "gravel|texture||diffuse|1024|1024|Volcano Rock||6|0.457 0.463 0.461 1|0|0|0", "grass|texture||Grass_01|512|512|Grass Leaves||6|0.307 0.397 0.189 1|0|0|0", "grass_aestrin|texture||Grass_03|512|512|Grass Leaves Med||6|0.427 0.523 0.314 1|0|0|0", "grass_emerald|texture||Grass_02|512|512|Grass Leaves 1||6|0.311 0.427 0.28 1|0|0|0", "leaves|material_copy|tree leaves med|Tree Leaves 2|256|256|||0|0.629 0.701 0.477 1|0|1|0", "crop_leafy|texture||LGW_d37|512|512|||0|0.378 0.512 0.159 1|0|1|0", "crop_wheat|texture||LGW_d35|512|512|||0|0.548 0.549 0.286 1|0|1|0",
			"crop_vine|texture||LGW_d43|512|512|||0|0.409 0.552 0.172 1|0|1|0", "crop_bush|texture||LGW_d36|256|512|||0|0.361 0.471 0.16 1|0|1|0", "crop_flower|texture||LGW_d33|256|512|||0|0.52 0.397 0.269 1|0|1|0", "flat_grass|flat_material|grass||0|0|||0|0.193 0.301 0.089 1|0|0|0", "water|flat_material|test water||0|0|||0|0.221 0.354 0.537 0.467|0|0|0", "glass|game_glass|glass window transparent||0|0|||0||0|0|0", "keep|keep|||0|0|||0||0|0|0", "hide|hide|||0|0|||0||0|0|0", "already|already|||0|0|||0||0|0|0", "flat_ink_bottle_redd|flat_material|ink bottle redd||0|0|||0|0.387 0.071 0.071 1|0|0|0"
		};

		internal static readonly string[] RowTable = new string[379]
		{
			"farm_glass_sh|already|glass|", "farm_abbeygamemat_kind_sh|already|stone or rock|", "farm_abbeyplainmat_kind_sh|already|paint or colour only|", "farm_dock_and_farm_stone_warm_grey|stone_aestrin|stone or rock|128 118 104", "farm_wire_dark_iron|iron|iron or metal|44 42 40", "farm_vine_post_bark|bark|bark or log|74 54 38", "farm_grape_vine_leaves|leaves|ivy or leaves|58 108 38", "farm_grapes|keep|crop|", "farm_mulch|mulch|earth or soil|86 60 42", "farm_fir_trim_fir_trim_jpg|boards_aestrin|wood beam or timber|",
			"farm_garden_soil|soil|earth or soil|78 56 40", "farm_dug_ridges_crop_rows|field|earth or soil|", "farm_bolts|iron|iron or metal|40 38 36", "farm_abbey_wall_stain_moss_and_dirt_overlay|hide|paint or colour only|", "farm_oak_beam_oak_beam_jpg|beam|wood beam or timber|", "farm_chronos_garden_earth|soil|earth or soil|92 66 44", "farm_fir_floor_boards_fir_floor_jpg|boards_aestrin|wood boards|", "farm_iron_chronos_tamarack_fallback|iron|iron or metal|60 60 62", "farm_bark_chronos_log_piles|bark|bark or log|94 72 52", "farm_terracotta_floor_tiles_chronos_fort_house|brick_red|brick|",
			"farm_chronos_fort_house_plaster|plaster_aestrin|plaster or render|214 200 176", "farm_chimney_cap_terracotta|terracotta|brick|150 84 58", "farm_wall_ivy_chronos|leaves|ivy or leaves|34 78 30", "farm_oak_boards_oak_boards_jpg|boards_aestrin|wood boards|", "farm_stepping_stones|stone_aestrin|stone or rock|150 144 132", "farm_chronos_house_plaster|plaster_aestrin|plaster or render|206 190 160", "farm_cedar_floor_boards_cedar_floor_jpg|boards_plain|wood boards|", "farm_chronos_house_stone|stone_aestrin|stone or rock|134 126 112", "farm_chronos_manor_floor_tiles_abbey_floor_picture_mu|brick_red|brick|", "farm_chronos_manor_dark_floor_tiles|brick_red|brick|",
			"farm_fireplace_grate|iron|iron or metal|46 44 43", "farm_glass_farmsh|already|glass|", "farm_firebox_soot|soot|paint or colour only|38 34 31", "farm_hearth_and_surround_stone|stone_aestrin|stone or rock|146 138 124", "farm_house_rock_walls_fallback_when_the_island_has_no|rock|stone or rock|150 136 118", "farm_ceiling_planks_dark|boards_aestrin|wood boards|84 58 42", "farm_fey_house_plaster|plaster_aestrin|plaster or render|228 200 166", "farm_terracotta_floor_fey_house|brick_red|brick|", "farm_feyrockmat_terr|already|stone or rock|", "farm_furniture_wood_fey_house|boards_plain|wood boards|112 79 62",
			"farm_bedding_cloth_fey_house|canvas|canvas or cloth|226 214 188", "farm_feybakeground_terr_gx0_gz0_gw_gh_out_bsaid|already|earth or soil|", "farm_garden_ground_fallback|grass_aestrin|grass|132 140 92", "farm_brown_earth_fallback|soil|earth or soil|96 74 52", "farm_fey_house_plaster_warm|plaster_aestrin|plaster or render|238 196 150", "farm_flagstones_fey_house|stone_dressed|stone or rock|128 120 108", "farm_feygamerock_scen_terr_out_rocktile|already|stone or rock|", "farm_feydirtmat_terr_out_dirtfrom|already|earth or soil|", "farm_arcade_stucco_fallback_when_the_game_s_paint_is_|plaster_aestrin|plaster or render|176 150 132", "farm_coffee_cherries|keep|crop|118 20 24",
			"farm_cutout_fieldshader_null_fieldshader_farmsh_tex_c|already|crop|", "farm_cropmat_tea_bushes|already|crop|", "farm_coffee_soil|soil|earth or soil|98 74 52", "farm_coffee_mulch|mulch|earth or soil|64 44 30", "farm_shrine_plaster_white|plaster_aestrin|plaster or render|226 222 210", "farm_shrine_paper_glowing_shoji|keep|canvas or cloth|236 230 210", "farm_shrine_iron|iron|iron or metal|34 34 36", "farm_shrine_rope|rope|rope|184 160 102", "farm_shrine_paper_streamers|canvas|canvas or cloth|242 240 232", "farm_shrine_bronze|brass|iron or metal|158 124 70",
			"farm_shrine_sakaki_leaves|leaves|ivy or leaves|56 82 44", "farm_shrine_lantern_glow|keep|other|236 194 130", "farm_shrine_red_lacquer|flat_ink_bottle_redd|paint or colour only|122 34 28", "farm_shrine_stone|stone_dressed|stone or rock|122 118 110", "farm_fort_courtyard_slabs|paving_grey|stone or rock|150 143 133", "farm_fort_courtyard_seams_dark_joint_lines_over_the_s|keep|other|", "farm_fort_gravel_walks|gravel|sand|", "farm_farm_timber_farmtimber|boards_aestrin|wood beam or timber|96 61 42", "farm_farm_boards_farmboards|boards_aestrin|wood boards|104 66 46", "farm_fort_english_grass_a_terrain_layer_of_ours|grass_aestrin|grass|",
			"farm_terracotta_planters_fort_garden|terracotta|paint or colour only|", "farm_pale_sign_board_kicia_bay|keep|paint or colour only|", "farm_dark_wood_lamp_post|boards_aestrin|wood beam or timber|46 40 35", "farm_lamp_iron|iron|iron or metal|40 40 42", "farm_garden_tool_handles|boards_aestrin|wood beam or timber|74 54 38", "farm_garden_tool_iron|iron|iron or metal|92 94 96", "farm_watering_can_tin|tin|iron or metal|118 120 116", "farm_canvas_sack|canvas|canvas or cloth|170 142 102", "farm_garden_pot_terracotta|terracotta|paint or colour only|166 92 62", "farm_garden_pot_soil|soil|earth or soil|30 22 16",
			"farm_potted_tree_trunk|bark|bark or log|92 70 50", "farm_potted_crop_fruit_colour_per_crop|keep|crop|", "farm_grc_sun_shades_canvas|canvas|canvas or cloth|", "farm_grc_house_plaster|plaster_alankh|plaster or render|226 198 160", "farm_cedar_trim_cedar_trim_jpg|beam|wood beam or timber|", "farm_crocus_flowers_grc_roof_garden|crop_flower|crop|", "farm_fireplace_logs_bark|bark|bark or log|", "farm_fireplace_firedogs|iron|iron or metal|", "farm_cedar_boards_cedar_boards_jpg|boards_emerald|wood boards|", "farm_kicia_house_plaster|plaster_aestrin|plaster or render|230 218 194",
			"farm_kicia_house_shoji_paper|canvas|canvas or cloth|236 230 212", "farm_kicia_house_stone|stone_dressed|stone or rock|124 120 114", "farm_kicia_house_ridge_grey|stone_blocks_grey|roof tile|70 72 76", "farm_kicia_house_tatami_woven_rush|thatch|thatch|", "farm_coconuts_lion_s_fang|keep|crop|96 70 40", "farm_lion_s_fang_plaster|plaster_alankh|plaster or render|180 146 121", "farm_lion_s_fang_stone|stone_dressed|stone or rock|128 105 87", "farm_lion_s_fang_logs|bark|bark or log|112 79 62", "farm_lion_s_fang_roof_tiles|roof_aestrin|roof tile|166 108 84", "farm_brick_lion_s_fang|brick_red|brick|",
			"farm_lion_s_fang_canvas|canvas|canvas or cloth|226 214 188", "farm_iron_lion_s_fang_4_uses|iron|iron or metal|46 44 42", "farm_malefic_barn_roof_tiles|roof_aestrin|roof tile|150 92 72", "farm_malefic_house_plaster|plaster_aestrin|plaster or render|214 202 182", "farm_terracotta_floor_malefic_house|brick_red|brick|", "farm_lime_tree_trunks|bark|bark or log|104 90 70", "farm_lime_tree_leaves|leaves|ivy or leaves|28 64 28", "farm_limes_on_the_trees|keep|crop|118 158 52", "farm_oasis_well_frame_wood|beam|wood beam or timber|98 68 48", "farm_oasis_water_ripples_normal_map|keep|other|",
			"farm_oasis_packed_shell_path|sand|sand|", "farm_old_ankh_window_glass|glass|glass|", "farm_akcutmat_akhillpaint_the_hill_cliff_home_s_cuts|already|other|", "farm_akcutmat_roompaint_the_copied_tavern_room_its_ba|already|other|", "farm_akcutmat_was_d4_s_pilasters_the_west_one_cut|already|other|", "farm_saffron_book_cover_leather|keep|paint or colour only|96 46 36", "farm_saffron_book_pages|keep|other|226 214 184", "farm_seed_card|keep|other|230 218 186", "farm_pavilion_canvas_saffron_farm|canvas|canvas or cloth|224 208 170", "farm_wisteria_stems|bark|bark or log|92 74 52",
			"farm_wisteria_leaves|leaves|ivy or leaves|70 120 40", "farm_wisteria_flowers|keep|ivy or leaves|", "farm_yard_tool_handles|beam|wood beam or timber|74 54 38", "farm_yard_tool_iron|iron|iron or metal|92 94 96", "farm_canvas_sack_saffron_yard|canvas|canvas or cloth|170 142 102", "farm_compost|mulch|earth or soil|64 46 32", "farm_speech_bubble|keep|other|", "farm_pale_weathered_sign_board|keep|paint or colour only|218 203 170", "farm_black_frame|soot|paint or colour only|20 18 16", "farm_seed_label|keep|other|160 136 112",
			"farm_wall_ivy_saffron|leaves|ivy or leaves|", "farm_saffron_gravel|gravel|sand|", "farm_saffron_soil_fields|field|earth or soil|", "farm_market_awning|canvas|canvas or cloth|214 196 158", "farm_fig_trunks|bark|bark or log|150 142 128", "farm_fig_leaves|leaves|ivy or leaves|56 104 40", "farm_figs|keep|crop|104 52 112", "farm_orchard_tree_trunks|bark|bark or log|96 78 58", "farm_palm_stems_banana|bark_palm|bark or log|108 120 72", "farm_orange_tree_leaves|leaves|ivy or leaves|30 70 28",
			"farm_apple_tree_leaves|leaves|ivy or leaves|52 98 40", "farm_oranges|keep|crop|238 140 30", "farm_apples|keep|crop|196 50 40", "farm_banana_fronds|leaves|crop|", "farm_banana_hands|keep|crop|", "farm_banana_hearts|keep|crop|", "farm_tobacco_stalks|flat_grass|crop|110 140 70", "farm_tobacco_leaves|crop_leafy|crop|", "farm_tobacco_flowers|crop_flower|crop|232 150 190", "farm_blue_tobacco_leaves|crop_leafy|crop|52 88 66",
			"farm_blue_tobacco_sugar_leaves|crop_leafy|crop|70 118 72", "farm_blue_tobacco_buds|crop_flower|crop|104 72 130", "farm_green_tobacco_leaves|crop_leafy|crop|46 92 38", "farm_green_tobacco_sugar_leaves|crop_leafy|crop|60 110 46", "farm_green_tobacco_buds|crop_flower|crop|78 122 60", "farm_carrot_tops|crop_leafy|crop|", "farm_potato_plants|crop_leafy|crop|40 92 34", "farm_cucumber_vines|crop_vine|crop|", "farm_cucumbers|keep|crop|58 112 40", "farm_sweet_potato_vines|crop_vine|crop|",
			"farm_cucumber_pea_stakes|beam|wood beam or timber|150 128 96", "farm_wheat|crop_wheat|crop|", "farm_cabbage_leaves|crop_leafy|crop|", "farm_cabbage_heads|keep|crop|166 190 122", "farm_pea_vines|crop_vine|crop|", "farm_tea_bushes_ours|crop_bush|crop|30 70 34", "farm_mushroom_stems|keep|crop|222 212 192", "farm_cave_mushroom_caps|keep|crop|196 178 150", "farm_field_mushroom_caps|keep|crop|138 98 66", "farm_coffeeleafmat|already|crop|",
			"farm_rice|crop_wheat|crop|", "farm_saffron_adobe_walls|plaster_alankh|plaster or render|180 146 121", "farm_saffron_fort_stone_3_uses|stone_dressed|stone or rock|128 105 87", "farm_saffron_roof_tiles|roof_aestrin|roof tile|166 108 84", "farm_saffron_boards_colour_from_the_fort_s_palette|boards_plain|wood boards|", "farm_saffron_timber_colour_from_the_fort_s_palette|beam|wood beam or timber|", "farm_saffron_fort_stonework_five_tints|stone_dressed|stone or rock|", "farm_saffron_fort_mortar_dark|stone_blocks_grey|stone or rock|82 78 72", "farm_fire_flame_sheet|keep|other|", "farm_lighthouse_beam|keep|other|",
			"farm_fire_glow_blob|keep|other|", "farm_gamepiermat_buildings_e_paint_swamp_buildings_e_|already|wood boards|", "farm_gamepiermat_buildings_e_paint_buildings_e_paint|already|wood boards|", "farm_gamepiermat_buildings_a_paint_buildings_a_paint|already|wood boards|", "farm_sage_hills_parchment_tan|keep|paint or colour only|200 165 110", "farm_parchment_rolls|keep|paint or colour only|184 146 96", "farm_parchment_nails|iron|iron or metal|40 36 32", "farm_sage_hills_barn_timber|beam|wood beam or timber|70 46 40", "farm_sage_hills_barn_boards|boards_emerald|wood boards|92 62 52", "farm_seed_catalogue_cover_green|keep|other|46 82 52",
			"farm_seedling_soil|soil|earth or soil|52 38 28", "farm_green_painted_boards_green_boards_jpg_sen_na_ins|boards_emerald|wood boards|", "farm_sen_na_window_glass|glass|glass|", "farm_oasis_barn_boards|boards_plain|wood boards|", "farm_oasis_barn_floor_tiles|paving_grey|stone or rock|", "farm_barn_sign_text|keep|other|", "farm_estate_sign_text|keep|other|", "farm_for_sale_sign_text|keep|other|", "farm_oasis_house_roof_logs_inside|beam|wood beam or timber|", "farm_oasis_fence_wood|beam|wood beam or timber|104 66 46",
			"farm_gamemat_face_mat|already|other|", "farm_gamemat_npc_alankh|already|other|", "mt_dkcloverpicture_out_pic|already|ivy or leaves|", "mt_dalkey_larch_bark_atlas_with_needles|bark|bark or log|", "mt_dalkey_larch_needles|leaves|ivy or leaves|", "mt_tamarack_lighthouse_boards|boards_aestrin|wood boards|", "mt_lighthouse_beam|keep|other|", "mt_lighthouse_flame_sheet|keep|other|", "mt_lighthouse_fire_blob|keep|other|", "mt_lighthouse_hooks_iron|iron|iron or metal|",
			"mt_reef_kelp|keep|other|", "mt_reef_foam|keep|water|", "mt_snow_drift_patches|keep|other|", "mt_snowflakes|keep|other|", "mt_snow_clean|keep|other|", "mt_snow_trodden|keep|other|", "mt_glass|already|glass|", "mt_cistern_water_ripples_normal_map|keep|water|", "mt_camp_oak_fallback_when_the_bundle_is_missing|boards_aestrin|wood beam or timber|92 70 50", "mt_camp_boards_fallback|boards_aestrin|wood boards|170 140 104",
			"mt_camp_weathered_boards_fallback|boards_aestrin|wood boards|120 112 102", "mt_camp_log_bark_the_larches_bark|bark|bark or log|", "mt_camp_bark_fallback|bark|bark or log|94 72 52", "mt_camp_log_ends_rings|wood_light|bark or log|", "mt_camp_iron|iron|iron or metal|60 60 62", "mt_camp_tent_canvas|canvas|canvas or cloth|", "mt_camp_stone_fallback|stone_aestrin|stone or rock|140 136 128", "mt_camp_rope|rope|rope|150 128 96", "mt_camp_straw_ticking_mattress|canvas|canvas or cloth|170 152 116", "mt_well_s_depth_black|keep|other|10 13 13",
			"mt_camp_earth_fallback|path|earth or soil|150 128 100", "mt_lantern_post_wood_camp|beam|wood beam or timber|76 61 48", "mt_lantern_iron_camp|iron|iron or metal|26 26 26", "mt_ledger_leather|keep|other|96 46 36", "mt_ledger_pages|keep|other|226 214 184", "mt_tobacco_trade_buttons_ui_tobmat_0_3|keep|other|", "mt_tower_fireplace_logs_bark|bark|bark or log|", "mt_happy_bay_walkway_timber|boards_aestrin|wood beam or timber|104 95 84", "mt_happy_bay_walkway_boards|boards_aestrin|wood boards|121 110 96", "mt_happy_bay_walkway_boards_2|boards_aestrin|wood boards|112 102 90",
			"mt_happy_bay_walkway_piles|boards_aestrin|wood beam or timber|78 70 62", "mt_trail_earth|path|earth or soil|", "mt_trail_packed_earth_solid|path|earth or soil|", "mt_drytex_t_nm_lgw_d45_goldstraw_straw_0_88f|already|grass|", "mt_drytex_cl_mosstone_0_62f|already|grass|", "mt_hillmaterial_ctx_island|already|earth or soil|", "mt_gamedockmat_buildings_a_paint_buildings_a_paint_|already|wood boards|", "mt_gamedockmat_buildings_e_paint_buildings_e_paint_|already|wood boards|", "mt_gamemat_face_mat|already|other|", "mt_gamemat_npc_alankh|already|other|",
			"bs_worn_cast_iron_stoves|iron|iron or metal|", "bs_stove_handle_wood_turned|wood_warm|wood beam or timber|", "bs_stove_window_glass_copies_a_game_bottle_glass_wh|glass|glass|", "bs_gallus_glass_pane_cabin_stove|glass|glass|", "bs_unlit_pane_cabin_stove|glass|glass|", "bs_hearth_bricks_grime_brick_galley|brick_red|brick|", "bs_hearth_copper_sheets_grimed|brass|iron or metal|", "bs_hearth_spark_screen_wire|iron|iron or metal|", "vit_pie_lattice_pie_lattice_jpg|keep|food|", "vit_pie_crust_pie_crust_jpg|keep|food|",
			"vit_pie_filling_pie_filling_jpg|keep|food|", "vit_pie_crumble_pie_crumble_jpg|keep|food|", "vit_pie_filling_darker|keep|food|219 209 204", "vit_pie_mash_top_pie_mash_jpg|keep|food|", "vit_shepherd_s_pie_filling_pie_filling_shep_jpg|keep|food|", "vit_plain_pie_filling_pie_filling_plain_jpg|keep|food|", "vit_pudding_skin_pud_jpg|keep|food|", "vit_pudding_inside_pud_jpg|keep|food|", "vit_scrambled_egg|keep|food|", "vit_raw_egg|keep|food|",
			"vit_rice|keep|food|", "vit_coconut_flesh|keep|food|", "vit_meat_hunk|keep|food|", "vit_beef|keep|food|", "vit_egg_shell|keep|food|", "vit_fried_egg|keep|food|", "vit_dough|keep|food|", "vit_bookmaterial_cr_sharedmaterial_out_drawn|already|other|", "vit_bookmaterial_lr_sharedmaterial_out_d2|already|other|", "vit_bookmaterial_r_sharedmaterial_out_d3|already|other|",
			"vit_victualling_book_pages|keep|other|", "vit_paint_jar_color_white_0f_0_55f_t|already|other|", "vit_mill_wood_blotched|beam|wood beam or timber|", "vit_mill_basin_stone|stone_dressed|stone or rock|", "vit_millstone|stone_dressed|stone or rock|", "vit_burlap_sack_canvas|canvas|canvas or cloth|", "vit_mill_tent_canvas|canvas|canvas or cloth|", "vit_sack_stencil_lettering|keep|other|", "vit_dried_residue_per_liquid|keep|food|", "vit_dough_mound_in_a_pot|keep|food|219 204 168",
			"vit_dish_in_a_jar|keep|food|92 69 41", "vit_cask_staves_wood|boards_plain|wood boards|", "vit_cask_hoops_iron|iron|iron or metal|31 29 28", "vit_jar_cork|wood_light|other|", "vit_jar_wax_seal_red|flat_ink_bottle_redd|paint or colour only|97 19 17", "vit_straw_hen_nest|thatch|thatch|189 161 97", "vit_hen_feathers_colour|keep|other|140 82 41", "vit_hen_comb|keep|other|158 26 20", "vit_hen_beak|keep|other|209 158 64", "vit_chicken_hen_feathers_picture|keep|other|219 199 158",
			"vit_cabbage_shared_provisions|keep|food|", "vit_sack_of_peas_shared_provisions|keep|food|", "vit_lime_shared_provisions|keep|food|", "vit_cabbage_wedge_shared_provisions|keep|food|", "vit_pile_of_peas_shared_provisions|keep|food|", "vit_lime_slice_shared_provisions|keep|food|", "vit_sea_biscuit_shared_provisions|keep|food|", "mt_brick_wall|stone_dressed|brick|", "mt_brick_vault|stone_dressed|brick|", "mt_brick_grime|stone_dressed|brick|",
			"mt_firebrick|brick_red|brick|", "mt_paving|paving_grey|stone or rock|", "mt_ashlar|stone_dressed|stone or rock|", "mt_plaster|plaster_aestrin|plaster or render|", "mt_exterior|stone_rough|plaster or render|", "mt_hearth_slate|stone_blocks_grey|stone or rock|", "mt_green_boards|boards_aestrin|wood boards|", "mt_floor_boards|boards_aestrin|wood boards|", "mt_door_oak|beam|wood boards|", "mt_map_glass|glass|glass|140 166 178",
			"mt_map_iron|iron|iron or metal|28 28 28", "mt_map_soot|soot|paint or colour only|5 5 5", "mt_map_rope|rope_flat|rope|143 122 92", "mt_map_water|water|water|36 102 133", "farm_abbey_oak_boards|boards_aestrin|wood boards|", "farm_abbey_room_plaster|plaster_aestrin|plaster or render|", "farm_abbey_abbey_floor|brick_red|brick|", "farm_abbey_abbey_floor_dark|brick_red|brick|", "farm_abbey_abbey_flags|stone_dressed|stone or rock|", "farm_abbey_abbey_t00|boards_aestrin|wood beam or timber|",
			"farm_abbey_abbey_t02|boards_aestrin|wood beam or timber|", "farm_abbey_abbey_t03|keep|wood boards|", "farm_abbey_abbey_t04|keep|glass|", "farm_abbey_abbey_t05|boards_aestrin|wood beam or timber|", "farm_abbey_abbey_t06|stone_blocks_grey|stone or rock|", "farm_abbey_abbey_t07|boards_aestrin|wood beam or timber|", "farm_abbey_abbey_t08|boards_aestrin|wood beam or timber|", "farm_abbey_abbey_t01|glass|glass|", "farm_abbey_dark_fittings|iron|iron or metal|11 11 13", "bs_hearth_firebrick|brick_red|brick|",
			"bs_hearth_soot_films|keep|other|", "bs_pipe|iron|iron or metal|23 22 22", "bs_brass|brass|iron or metal|179 149 90", "bs_soot|soot|paint or colour only|11 9 8", "bs_copper|brass|iron or metal|140 77 43", "bs_brick_tints|brick_red|brick|140 77 54", "bs_mortar|stone_dressed|stone or rock|153 143 122", "bs_coals_ash|keep|other|18 5 3", "bs_bundle_pieces|keep|other|", "vit_beef_chop|keep|food|",
			"vit_beef_slice|keep|food|", "vit_hen_feathers|keep|other|", "vit_stencil_rice|keep|other|", "vit_stencil_flour|keep|other|", "vit_stencil_oats|keep|other|", "vit_mill_wood|keep|wood beam or timber|", "vit_mill_basin|keep|stone or rock|", "vit_mill_stone|keep|stone or rock|", "vit_slices_overlay|hide|food|", "farm_lamp_glass|keep|other|140 128 102",
			"farm_well_water|water|water|36 102 133", "farm_fire_coals|keep|other|230 115 38", "mt_lh_copper|brass|iron or metal|77 110 92", "mt_lh_iron|iron|iron or metal|26 26 26", "mt_lh_soot|soot|paint or colour only|18 15 14", "mt_lh_glass|glass|glass|184 217 242", "mt_lantern_post|beam|wood beam or timber|77 61 48", "mt_lantern_iron|iron|iron or metal|26 26 26", "mt_tin_cap|tin|iron or metal|120 125 128", "mt_pull_cord|rope_flat|rope|140 115 77",
			"mt_sale_board|keep|paint or colour only|219 212 189", "mt_seamarks|keep|paint or colour only|", "mt_fire_coals|keep|other|", "mt_lh_roof_brick02|already|roof tile|", "mt_lh_wood_boneisle|already|wood beam or timber|", "mt_pier_fortstone|already|stone or rock|", "mt_reef_granite|already|stone or rock|", "mt_dalkey_ground|already|earth or soil|", "mt_dalkey_terrain|already|grass|"
		};

		internal static readonly string[] SigTable = new string[260]
		{
			"farm:Mottled|64|128,118,104|223|farm_dock_and_farm_stone_warm_grey", "farm:Mottled|16|44,42,40|5|farm_wire_dark_iron", "farm:Mottled|64|74,54,38|61|farm_vine_post_bark", "farm:IvyTex|256|58,108,38|29|farm_grape_vine_leaves", "farm:Mottled|128|86,60,42|3413|farm_mulch", "farm:jpg|fir_trim.jpg|farm_fir_trim_fir_trim_jpg", "farm:Mottled|128|78,56,40|2207|farm_garden_soil", "farm:Mottled|16|40,38,36|7|farm_bolts", "farm:AbbeyStainMat|farm_abbey_wall_stain_moss_and_dirt_overlay", "farm:jpg|oak_beam.jpg|farm_oak_beam_oak_beam_jpg",
			"farm:Mottled|128|92,66,44|7711|farm_chronos_garden_earth", "farm:jpg|fir_floor.jpg|farm_fir_floor_boards_fir_floor_jpg", "farm:Mottled|64|60,60,62|9311|farm_iron_chronos_tamarack_fallback", "farm:Mottled|128|94,72,52|9313|farm_bark_chronos_log_piles", "farm:TerracottaTex|512|-|4473|farm_terracotta_floor_tiles_chronos_fort_house", "farm:TerracottaTex|512|-|4471|farm_terracotta_floor_tiles_chronos_fort_house", "farm:Mottled|128|214,200,176|8801|farm_chronos_fort_house_plaster", "farm:Mottled|64|150,84,58|8803|farm_chimney_cap_terracotta", "farm:IvyTex|256|34,78,30|4433|farm_wall_ivy_chronos", "farm:jpg|oak_boards.jpg|farm_oak_boards_oak_boards_jpg",
			"farm:Mottled|64|150,144,132|4453|farm_stepping_stones", "farm:Mottled|128|206,190,160|7701|farm_chronos_house_plaster", "farm:jpg|cedar_floor.jpg|farm_cedar_floor_boards_cedar_floor_jpg", "farm:Mottled|64|134,126,112|7703|farm_chronos_house_stone", "farm:ChTileMat|farm_chronos_manor_floor_tiles_abbey_floor_picture_mu", "farm:Mottled|32|46,44,43|8847|farm_fireplace_grate", "farm:Mottled|64|38,34,31|8841|farm_firebox_soot", "farm:Mottled|128|146,138,124|8843|farm_hearth_and_surround_stone", "farm:Mottled|128|150,136,118|907|farm_house_rock_walls_fallback_when_the_island_has_no", "farm:Planks|256|84,58,42|79|farm_ceiling_planks_dark",
			"farm:Mottled|128|228,200,166|1301|farm_fey_house_plaster", "farm:TerracottaTex|512|-|4403|farm_terracotta_floor_fey_house", "farm:Mottled|128|112,79,62|53|farm_furniture_wood_fey_house", "farm:Mottled|128|226,214,188|41|farm_bedding_cloth_fey_house", "farm:Mottled|64|132,140,92|77|farm_garden_ground_fallback", "farm:Mottled|128|96,74,52|2203|farm_brown_earth_fallback", "farm:Mottled|128|238,196,150|1301|farm_fey_house_plaster_warm", "farm:Tiles|256|128,120,108|6611|farm_flagstones_fey_house", "farm:Mottled|128|176,150,132|613|farm_arcade_stucco_fallback_when_the_game_s_paint_is_", "farm:Mottled|16|118,20,24|3301|farm_coffee_cherries",
			"farm:Mottled|128|98,74,52|3311|farm_coffee_soil", "farm:Mottled|128|64,44,30|3313|farm_coffee_mulch", "farm:Mottled|128|226,222,210|3101|farm_shrine_plaster_white", "farm:Mottled|64|236,230,210|3103|farm_shrine_paper_glowing_shoji", "farm:Mottled|32|34,34,36|3105|farm_shrine_iron", "farm:Mottled|64|184,160,102|3107|farm_shrine_rope", "farm:Mottled|32|242,240,232|3109|farm_shrine_paper_streamers", "farm:Mottled|64|158,124,70|3111|farm_shrine_bronze", "farm:Mottled|32|56,82,44|3113|farm_shrine_sakaki_leaves", "farm:Mottled|64|236,194,130|3115|farm_shrine_lantern_glow",
			"farm:Mottled|32|122,34,28|3117|farm_shrine_red_lacquer", "farm:Mottled|64|122,118,110|3119|farm_shrine_stone", "farm:CourtTex|256|150,143,133|317|farm_fort_courtyard_slabs", "farm:FortGravelTex|farm_fort_gravel_walks", "farm:Planks|256|96,61,42|73|farm_farm_timber_farmtimber", "farm:Planks|256|104,66,46|71|farm_farm_boards_farmboards", "farm:GrassTex|farm_fort_english_grass_a_terrain_layer_of_ours", "farm:TerracottaTex|512|-|4401|farm_terracotta_planters_fort_garden", "farm:Planks|128|46,40,35|4441|farm_dark_wood_lamp_post", "farm:Mottled|16|40,40,42|4443|farm_lamp_iron",
			"farm:Mottled|32|74,54,38|4425|farm_garden_tool_handles", "farm:Mottled|16|92,94,96|4427|farm_garden_tool_iron", "farm:Mottled|16|118,120,116|4429|farm_watering_can_tin", "farm:Mottled|32|170,142,102|4431|farm_canvas_sack", "farm:Mottled|64|166,92,62|6501|farm_garden_pot_terracotta", "farm:Mottled|64|30,22,16|6503|farm_garden_pot_soil", "farm:Mottled|16|92,70,50|6607|farm_potted_tree_trunk", "farm:GrcShadeTex|farm_grc_sun_shades_canvas", "farm:Mottled|128|226,198,160|2011|farm_grc_house_plaster", "farm:jpg|cedar_trim.jpg|farm_cedar_trim_cedar_trim_jpg",
			"farm:CrocusTex|farm_crocus_flowers_grc_roof_garden", "farm:BarkMat|farm_fireplace_logs_bark", "farm:IronMat|farm_fireplace_firedogs", "farm:jpg|cedar_boards.jpg|farm_cedar_boards_cedar_boards_jpg", "farm:Mottled|128|230,218,194|2711|farm_kicia_house_plaster", "farm:Mottled|64|236,230,212|2713|farm_kicia_house_shoji_paper", "farm:Mottled|64|124,120,114|2717|farm_kicia_house_stone", "farm:Mottled|64|70,72,76|2719|farm_kicia_house_ridge_grey", "farm:KhTatamiTex|farm_kicia_house_tatami_woven_rush", "farm:Mottled|16|96,70,40|311|farm_coconuts_lion_s_fang",
			"farm:Mottled|128|180,146,121|6101|farm_lion_s_fang_plaster", "farm:Mottled|64|128,105,87|6102|farm_lion_s_fang_stone", "farm:Mottled|64|112,79,62|6103|farm_lion_s_fang_logs", "farm:Tiles|256|166,108,84|6104|farm_lion_s_fang_roof_tiles", "farm:Brick|farm_brick_lion_s_fang", "farm:Mottled|128|226,214,188|6105|farm_lion_s_fang_canvas", "farm:Mottled|64|46,44,42|571|farm_iron_lion_s_fang_4_uses", "farm:Tiles|256|150,92,72|83|farm_malefic_barn_roof_tiles", "farm:Mottled|128|214,202,182|1301|farm_malefic_house_plaster", "farm:TerracottaTex|512|-|4402|farm_terracotta_floor_malefic_house",
			"farm:Mottled|64|104,90,70|4213|farm_lime_tree_trunks", "farm:IvyTex|256|28,64,28|4215|farm_lime_tree_leaves", "farm:Mottled|64|98,68,48|307|farm_oasis_well_frame_wood", "farm:ShellTex|farm_oasis_packed_shell_path", "farm:AkGlass|farm_old_ankh_window_glass", "farm:Mottled|32|96,46,36|211|farm_saffron_book_cover_leather", "farm:Mottled|32|226,214,184|213|farm_saffron_book_pages", "farm:Mottled|32|230,218,186|271|farm_seed_card", "farm:Mottled|64|224,208,170|195|farm_pavilion_canvas_saffron_farm", "farm:Mottled|16|92,74,52|133|farm_wisteria_stems",
			"farm:IvyTex|256|70,120,40|19|farm_wisteria_leaves", "farm:Mottled|32|74,54,38|221|farm_yard_tool_handles", "farm:Mottled|16|92,94,96|223|farm_yard_tool_iron", "farm:Mottled|32|170,142,102|225|farm_canvas_sack_saffron_yard", "farm:Mottled|32|64,46,32|227|farm_compost", "farm:Mottled|128|218,203,170|9321|farm_pale_weathered_sign_board", "farm:Mottled|8|20,18,16|179|farm_black_frame", "farm:Mottled|32|160,136,112|263|farm_seed_label", "farm:IvyTex|256|*|11|farm_wall_ivy_saffron", "farm:GravelTex|farm_saffron_gravel",
			"farm:SoilTex|farm_saffron_soil_fields", "farm:Mottled|64|214,196,158|131|farm_market_awning", "farm:Mottled|64|150,142,128|165|farm_fig_trunks", "farm:IvyTex|256|56,104,40|79|farm_fig_leaves", "farm:Mottled|64|96,78,58|161|farm_orchard_tree_trunks", "farm:Mottled|64|108,120,72|163|farm_palm_stems_banana", "farm:IvyTex|256|30,70,28|71|farm_orange_tree_leaves", "farm:IvyTex|256|52,98,40|73|farm_apple_tree_leaves", "farm:BananaBladeTex|farm_banana_fronds", "farm:Mottled|16|110,140,70|201|farm_tobacco_stalks",
			"farm:TobaccoLeafTex|farm_tobacco_leaves", "farm:FlowerHeadTex|32|232,150,190|-|farm_tobacco_flowers", "farm:PalmateLeafTex|128|52,88,66|-|farm_blue_tobacco_leaves", "farm:PalmateLeafTex|64|70,118,72|-|farm_blue_tobacco_sugar_leaves", "farm:BudTex|48|104,72,130|-|farm_blue_tobacco_buds", "farm:PalmateLeafTex|128|46,92,38|-|farm_green_tobacco_leaves", "farm:PalmateLeafTex|64|60,110,46|-|farm_green_tobacco_sugar_leaves", "farm:BudTex|48|78,122,60|-|farm_green_tobacco_buds", "farm:CarrotTex|farm_carrot_tops", "farm:IvyTex|128|40,92,34|77|farm_potato_plants",
			"farm:CucumberTex|farm_cucumber_vines", "farm:Mottled|16|58,112,40|171|farm_cucumbers", "farm:SweetPotatoTex|farm_sweet_potato_vines", "farm:Mottled|32|150,128,96|181|farm_cucumber_pea_stakes", "farm:WheatTex|farm_wheat", "farm:CabbageLeafTex|farm_cabbage_leaves", "farm:Mottled|16|166,190,122|951|farm_cabbage_heads", "farm:PeaVineTex|farm_pea_vines", "farm:IvyTex|128|30,70,34|191|farm_tea_bushes_ours", "farm:Mottled|16|222,212,192|241|farm_mushroom_stems",
			"farm:Mottled|32|196,178,150|243|farm_cave_mushroom_caps", "farm:Mottled|32|138,98,66|245|farm_field_mushroom_caps", "farm:Mottled|128|180,146,121|11|farm_saffron_adobe_walls", "farm:Mottled|128|128,105,87|23|farm_saffron_fort_stone_3_uses", "farm:Tiles|256|166,108,84|83|farm_saffron_roof_tiles", "farm:Planks|256|*|71|farm_saffron_boards_colour_from_the_fort_s_palette", "farm:Planks|256|*|73|farm_saffron_timber_colour_from_the_fort_s_palette", "farm:Mottled|128|*|101|farm_saffron_fort_stonework_five_tints", "farm:Mottled|128|*|102|farm_saffron_fort_stonework_five_tints", "farm:Mottled|128|*|103|farm_saffron_fort_stonework_five_tints",
			"farm:Mottled|128|*|104|farm_saffron_fort_stonework_five_tints", "farm:Mottled|128|*|105|farm_saffron_fort_stonework_five_tints", "farm:Mottled|64|82,78,72|91|farm_saffron_fort_mortar_dark", "farm:Mottled|128|200,165,110|8803|farm_sage_hills_parchment_tan", "farm:Mottled|64|184,146,96|8807|farm_parchment_rolls", "farm:Mottled|32|40,36,32|8809|farm_parchment_nails", "farm:Mottled|128|70,46,40|6113|farm_sage_hills_barn_timber", "farm:Planks|256|92,62,52|6127|farm_sage_hills_barn_boards", "farm:Mottled|32|46,82,52|6311|farm_seed_catalogue_cover_green", "farm:Mottled|64|52,38,28|6303|farm_seedling_soil",
			"farm:jpg|green_boards.jpg|farm_green_painted_boards_green_boards_jpg_sen_na_ins", "farm:SnGlassMat|farm_sen_na_window_glass", "farm:FloorTiles|farm_oasis_barn_floor_tiles", "farm:Planks|256|*|79|farm_oasis_house_roof_logs_inside", "farm:Planks|256|104,66,46|91|farm_oasis_fence_wood", "mt:DkBarkAtlas|mt_dalkey_larch_bark_atlas_with_needles", "mt:DkNeedleAtlas|mt_dalkey_larch_needles", "mt:LhPlanks|mt_tamarack_lighthouse_boards", "mt:IronMat|mt_lighthouse_hooks_iron", "mt:CampMottled|64|92,70,50|7101|mt_camp_oak_fallback_when_the_bundle_is_missing",
			"mt:CampMottled|64|170,140,104|7103|mt_camp_boards_fallback", "mt:CampMottled|64|120,112,102|7105|mt_camp_weathered_boards_fallback", "mt:DkLogBarkMat|mt_camp_log_bark_the_larches_bark", "mt:CampMottled|128|94,72,52|9313|mt_camp_bark_fallback", "mt:CampRings|mt_camp_log_ends_rings", "mt:CampMottled|64|60,60,62|9311|mt_camp_iron", "mt:CampCanvas|mt_camp_tent_canvas", "mt:CampMottled|64|140,136,128|7141|mt_camp_stone_fallback", "mt:CampMottled|32|150,128,96|9401|mt_camp_rope", "mt:CampMottled|64|170,152,116|9411|mt_camp_straw_ticking_mattress",
			"mt:CampMat|well's depth|mt_well_s_depth_black", "mt:CampMottled|64|150,128,100|7151|mt_camp_earth_fallback", "mt:CampMat|lantern post|mt_lantern_post_wood_camp", "mt:CampMat|lantern iron|mt_lantern_iron_camp", "mt:CampMottled|32|96,46,36|7211|mt_ledger_leather", "mt:CampMottled|32|226,214,184|7213|mt_ledger_pages", "mt:BarkMat|mt_tower_fireplace_logs_bark", "bs:ScuffTexture|bs_worn_cast_iron_stoves", "bs:WoodTexture|bs_stove_handle_wood_turned", "bs:GlassMaterial|bs_stove_window_glass_copies_a_game_bottle_glass_wh",
			"bs:GallusGlass|bs_gallus_glass_pane_cabin_stove", "bs:UnlitPane|bs_unlit_pane_cabin_stove", "bs:GrimeTexture|512|-|1750|bs_hearth_bricks_grime_brick_galley", "bs:GrimeTexture|512|-|1777|bs_hearth_copper_sheets_grimed", "bs:WireScreenTexture|bs_hearth_spark_screen_wire", "vit:Paint|pie_lattice.jpg|vit_pie_lattice_pie_lattice_jpg", "vit:Paint|pie_crust.jpg|vit_pie_crust_pie_crust_jpg", "vit:Paint|pie_filling.jpg|vit_pie_filling_pie_filling_jpg", "vit:Paint|pie_crumble.jpg|vit_pie_crumble_pie_crumble_jpg", "vit:Paint|pie_mash.jpg|vit_pie_mash_top_pie_mash_jpg",
			"vit:Paint|pie_filling_shep.jpg|vit_shepherd_s_pie_filling_pie_filling_shep_jpg", "vit:Paint|pie_filling_plain.jpg|vit_plain_pie_filling_pie_filling_plain_jpg", "vit:BlotchTex|mill wood|vit_mill_wood_blotched", "vit:BlotchTex|mill basin|vit_mill_basin_stone", "vit:BlotchTex|mill stone|vit_millstone", "vit:BurlapTex|vit_burlap_sack_canvas", "vit:TentCanvasTex|vit_mill_tent_canvas", "vit:Paint|dough mound|vit_dough_mound_in_a_pot", "vit:Paint|dish in a jar|vit_dish_in_a_jar", "vit:WoodTexture|vit_cask_staves_wood",
			"vit:Paint|cask iron|vit_cask_hoops_iron", "vit:CorkTexture|vit_jar_cork", "vit:Paint|jar wax|vit_jar_wax_seal_red", "vit:Paint|straw|vit_straw_hen_nest", "vit:Paint|hen |vit_hen_feathers_colour", "vit:Paint|hen comb|vit_hen_comb", "vit:Paint|hen beak|vit_hen_beak", "vit:Paint|chicken|vit_chicken_hen_feathers_picture", "mt:bundle|brick_wall|mt_brick_wall", "mt:bundle|brick_vault|mt_brick_vault",
			"mt:bundle|brick_grime|mt_brick_grime", "mt:bundle|firebrick|mt_firebrick", "mt:bundle|paving|mt_paving", "mt:bundle|ashlar|mt_ashlar", "mt:bundle|plaster|mt_plaster", "mt:bundle|exterior|mt_exterior", "mt:bundle|hearth_slate|mt_hearth_slate", "mt:bundle|green_boards|mt_green_boards", "mt:bundle|floor_boards|mt_floor_boards", "mt:bundle|door_oak|mt_door_oak",
			"farm:abbeybundle|oak_boards|farm_abbey_oak_boards", "farm:abbeybundle|room_plaster|farm_abbey_room_plaster", "farm:abbeybundle|abbey_floor|farm_abbey_abbey_floor", "farm:abbeybundle|abbey_floor_dark|farm_abbey_abbey_floor_dark", "farm:abbeybundle|abbey_flags|farm_abbey_abbey_flags", "farm:abbeybundle|abbey_t00|farm_abbey_abbey_t00", "farm:abbeybundle|abbey_t02|farm_abbey_abbey_t02", "farm:abbeybundle|abbey_t03|farm_abbey_abbey_t03", "farm:abbeybundle|abbey_t04|farm_abbey_abbey_t04", "farm:abbeybundle|abbey_t05|farm_abbey_abbey_t05",
			"farm:abbeybundle|abbey_t06|farm_abbey_abbey_t06", "farm:abbeybundle|abbey_t07|farm_abbey_abbey_t07", "farm:abbeybundle|abbey_t08|farm_abbey_abbey_t08", "farm:abbeybundle|abbey_t01|farm_abbey_abbey_t01", "bs:bundle|firebrick|bs_hearth_firebrick", "vit:bundle|beef_chop|vit_beef_chop", "vit:bundle|beef_slice|vit_beef_slice", "vit:bundle|hen_feathers|vit_hen_feathers", "vit:bundle|stencil_rice|vit_stencil_rice", "vit:bundle|stencil_flour|vit_stencil_flour",
			"vit:bundle|stencil_oats|vit_stencil_oats", "vit:bundle|mill_wood|vit_mill_wood", "vit:bundle|mill_basin|vit_mill_basin", "vit:bundle|mill_stone|vit_mill_stone", "vit:jpg|slices_overlay.png|vit_slices_overlay", "mt:map|Iron|mt_map_iron", "mt:map|Soot|mt_map_soot", "mt:map|Rope|mt_map_rope", "mt:map|Water|mt_map_water", "farm:abbeycolour|0.045 0.045 0.05 1.0|farm_abbey_dark_fittings"
		};

		internal static string Mode
		{
			get
			{
				string text = ((_cfg != null) ? _cfg.Value : "Detailed");
				if (!(text == "Plain") && !(text == "Stock Sailwind"))
				{
					return "Detailed";
				}
				return text;
			}
		}

		internal static bool IsStock => Mode == "Stock Sailwind";

		private static string ScopeOf(string asm)
		{
			return asm switch
			{
				"SailwindFarming" => "farm", 
				"MartelloTower" => "mt", 
				"BetterStoves" => "bs", 
				"Vittles" => "vit", 
				_ => asm, 
			};
		}

		private static float F(string s)
		{
			if (!float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return result;
		}

		private static float[] Fs(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return new float[0];
			}
			string[] array = s.Split(new char[1] { ' ' });
			float[] array2 = new float[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = F(array[i]);
			}
			return array2;
		}

		private static void Tables()
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_0226: 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)
			if (_picks != null)
			{
				return;
			}
			Dictionary<string, Pick> dictionary = new Dictionary<string, Pick>();
			Dictionary<string, Row> dictionary2 = new Dictionary<string, Row>();
			Dictionary<string, string> dictionary3 = new Dictionary<string, string>();
			string[] pickTable = PickTable;
			for (int i = 0; i < pickTable.Length; i++)
			{
				string[] array = pickTable[i].Split(new char[1] { '|' });
				if (array.Length >= 13)
				{
					Pick pick = new Pick
					{
						key = array[0],
						mode = array[1],
						mat = array[2],
						tex = array[3],
						w = (int)F(array[4]),
						h = (int)F(array[5]),
						layer = array[6],
						tile = F(array[8]),
						fromOurs = (array[10] == "1"),
						card = (array[11] == "1"),
						turned = (array[12] == "1")
					};
					float[] array2 = Fs(array[7]);
					if (array2.Length == 4)
					{
						pick.hasUv = true;
						pick.uv = new Rect(array2[0], array2[1], array2[2], array2[3]);
					}
					float[] array3 = Fs(array[9]);
					if (array3.Length >= 3)
					{
						pick.hasFlat = true;
						pick.flat = new Color(array3[0], array3[1], array3[2], (array3.Length > 3) ? array3[3] : 1f);
					}
					dictionary[pick.key] = pick;
				}
			}
			pickTable = RowTable;
			for (int i = 0; i < pickTable.Length; i++)
			{
				string[] array4 = pickTable[i].Split(new char[1] { '|' });
				if (array4.Length >= 4)
				{
					Row row = new Row
					{
						id = array4[0],
						pick = array4[1],
						kind = array4[2]
					};
					float[] array5 = Fs(array4[3]);
					if (array5.Length >= 3)
					{
						row.hasOurs = true;
						row.ours = new Color(array5[0] / 255f, array5[1] / 255f, array5[2] / 255f, 1f);
					}
					if (!dictionary2.ContainsKey(row.id))
					{
						dictionary2[row.id] = row;
					}
				}
			}
			string text = Scope + ":";
			pickTable = SigTable;
			foreach (string text2 in pickTable)
			{
				int num = text2.LastIndexOf('|');
				if (num > 0)
				{
					string text3 = text2.Substring(0, num);
					if (text3.StartsWith(text, StringComparison.Ordinal))
					{
						dictionary3[text3.Substring(text.Length)] = text2.Substring(num + 1);
					}
				}
			}
			_picks = dictionary;
			_rows = dictionary2;
			_sigs = dictionary3;
		}

		internal static ConfigEntry<string> Bind(ConfigFile config)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			return config.Bind<string>("Look", "Texture look", "Detailed", new ConfigDescription("How this mod's buildings and things are painted. Detailed: our own pictures, as made. Plain: our own pictures, softer - half size, lightly blurred, less contrast, colours a little nearer their average. Stock Sailwind: the game's own closest material or picture for each (brick may become the game's red cobbles or plain stone; close enough). Food, flames, signs and books keep their own look. Takes effect as you change it (anything not caught then, on the next load).", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Detailed", "Plain", "Stock Sailwind" }), Array.Empty<object>()));
		}

		internal static void Start(ConfigEntry<string> cfg, GameObject host, Action<string> log, string who, bool perPart = false)
		{
			_cfg = cfg;
			_log = log;
			_who = who ?? "";
			_perPart = perPart;
			if ((Object)(object)host != (Object)null && (Object)(object)host.GetComponent<TextureLookRunner>() == (Object)null)
			{
				host.AddComponent<TextureLookRunner>();
			}
			if (!_started && cfg != null)
			{
				_started = true;
				cfg.SettingChanged += delegate
				{
					_scanAt = 0f;
				};
			}
			Tables();
			Say("Texture look '" + Mode + "'" + ((Mode == "Detailed") ? " - every picture as made." : " - applied once the game is playing."));
		}

		internal static bool Hides(string rowId)
		{
			Tables();
			if (Mode == "Stock Sailwind" && _rows.TryGetValue(rowId, out var value))
			{
				return value.pick == "hide";
			}
			return false;
		}

		private static void Say(string s)
		{
			if (_log != null)
			{
				try
				{
					_log(s);
				}
				catch (Exception)
				{
				}
			}
		}

		internal static T Sig<T>(T tex, string maker, int size, Color32 c, int seed) where T : Texture
		{
			if ((Object)(object)tex == (Object)null)
			{
				return tex;
			}
			Tables();
			string text = c.r + "," + c.g + "," + c.b;
			string text2 = size.ToString(CultureInfo.InvariantCulture);
			string text3 = seed.ToString(CultureInfo.InvariantCulture);
			string text4 = Find(maker + "|" + text2 + "|" + text + "|" + text3) ?? Find(maker + "|" + text2 + "|*|" + text3) ?? Find(maker + "|*|*|" + text3) ?? Find(maker + "|" + text2 + "|" + text + "|*") ?? Find(maker + "|" + text2 + "|*|*");
			if (text4 != null)
			{
				Tag(tex, text4);
			}
			return tex;
		}

		internal static T Sig<T>(T tex, string maker, int size, Color32 c) where T : Texture
		{
			if ((Object)(object)tex == (Object)null)
			{
				return tex;
			}
			Tables();
			string text = Find(maker + "|" + size.ToString(CultureInfo.InvariantCulture) + "|" + c.r + "," + c.g + "," + c.b + "|-");
			if (text != null)
			{
				Tag(tex, text);
			}
			return tex;
		}

		internal static T Sig<T>(T tex, string maker, int size, int seed) where T : Texture
		{
			if ((Object)(object)tex == (Object)null)
			{
				return tex;
			}
			Tables();
			string text = Find(maker + "|" + size.ToString(CultureInfo.InvariantCulture) + "|-|" + seed.ToString(CultureInfo.InvariantCulture));
			if (text != null)
			{
				Tag(tex, text);
			}
			return tex;
		}

		internal static T Sig<T>(T tex, string key) where T : Texture
		{
			if ((Object)(object)tex == (Object)null)
			{
				return tex;
			}
			Tables();
			string text = Find(key);
			if (text != null)
			{
				Tag(tex, text);
			}
			return tex;
		}

		internal static Material SigMat(Material m, string key)
		{
			if ((Object)(object)m == (Object)null)
			{
				return m;
			}
			Tables();
			string text = Find(key);
			if (text != null)
			{
				TagMat(m, text);
			}
			return m;
		}

		private static string Find(string key)
		{
			if (_sigs == null || !_sigs.TryGetValue(key, out var value))
			{
				return null;
			}
			return value;
		}

		internal static T Tag<T>(T tex, string rowId) where T : Texture
		{
			if ((Object)(object)tex == (Object)null || string.IsNullOrEmpty(rowId))
			{
				return tex;
			}
			if (!_texIds.ContainsKey(((Object)(object)tex).GetInstanceID()))
			{
				_notOurs.Clear();
			}
			_texIds[((Object)(object)tex).GetInstanceID()] = rowId;
			Soon();
			return tex;
		}

		internal static Material TagMat(Material m, string rowId)
		{
			if ((Object)(object)m == (Object)null || string.IsNullOrEmpty(rowId))
			{
				return m;
			}
			_matIds[((Object)m).GetInstanceID()] = rowId;
			_notOurs.Remove(((Object)m).GetInstanceID());
			Soon();
			return m;
		}

		internal static void Keep(Transform root, string what)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			for (int num = _kept.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_kept[num] == (Object)null)
				{
					_kept.RemoveAt(num);
				}
				else if ((Object)(object)_kept[num] == (Object)(object)root)
				{
					return;
				}
			}
			_kept.Add(root);
			if (!_saidKept.Contains(what))
			{
				_saidKept.Add(what);
				Say(what + " keeps its own look in every Texture look (Roy has not OK'd changing it).");
			}
		}

		private static bool IsKept(Transform t)
		{
			if (_kept.Count == 0)
			{
				return false;
			}
			Transform val = t;
			while ((Object)(object)val != (Object)null)
			{
				for (int i = 0; i < _kept.Count; i++)
				{
					if ((Object)(object)_kept[i] == (Object)(object)val)
					{
						return true;
					}
				}
				val = val.parent;
			}
			return false;
		}

		internal static void Soon()
		{
			float unscaledTime = Time.unscaledTime;
			if (_scanAt < 0f || _scanAt > unscaledTime + 1.5f)
			{
				_scanAt = unscaledTime + 1.5f;
			}
			_scanAgainAt = unscaledTime + 8f;
		}

		internal static void Tick()
		{
			if (_cfg == null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			string mode = Mode;
			if (mode != _applied)
			{
				PutBack();
				string applied = _applied;
				_applied = mode;
				_scanAt = unscaledTime;
				_scanAgainAt = unscaledTime + 6f;
				Say("Texture look changed from '" + applied + "' to '" + mode + "'" + ((mode == "Detailed") ? " - everything back as made." : "."));
			}
			if (mode == "Detailed")
			{
				_queue.Clear();
				_queued.Clear();
				return;
			}
			bool flag = false;
			try
			{
				flag = GameState.playing && !GameState.currentlyLoading;
			}
			catch (Exception)
			{
			}
			if (!flag)
			{
				_playingSince = -1f;
				return;
			}
			if (_playingSince < 0f)
			{
				_playingSince = unscaledTime;
				_scanAt = unscaledTime + 3f;
				_scanAgainAt = unscaledTime + 12f;
			}
			if (unscaledTime - _playingSince < 3f)
			{
				return;
			}
			if (((_scanAt >= 0f && unscaledTime >= _scanAt) || (_scanAgainAt >= 0f && unscaledTime >= _scanAgainAt) || (_perPart && unscaledTime >= _nextRound)) && _queue.Count == 0)
			{
				if (_scanAt >= 0f && unscaledTime >= _scanAt)
				{
					_scanAt = -1f;
				}
				else if (_scanAgainAt >= 0f && unscaledTime >= _scanAgainAt)
				{
					_scanAgainAt = -1f;
				}
				_nextRound = unscaledTime + 20f;
				try
				{
					Look();
				}
				catch (Exception ex2)
				{
					Say("Texture look: the parts could not be looked over - " + ex2.Message);
				}
			}
			if (_queue.Count <= 0)
			{
				return;
			}
			Stopwatch stopwatch = Stopwatch.StartNew();
			while (_queue.Count > 0 && (stopwatch.ElapsedMilliseconds < 6 || stopwatch.ElapsedTicks == 0L))
			{
				Job job = _queue.Dequeue();
				try
				{
					Do(job, mode);
				}
				catch (Exception ex3)
				{
					Say("Texture look: one material could not be changed (" + job.id + ") - " + ex3.Message + " (it keeps its look)");
				}
			}
			if (_queue.Count == 0)
			{
				_queued.Clear();
				if (_changed > 0 || _parts > 0)
				{
					Say("Texture look '" + mode + "': " + _changed + " material(s) changed" + (_perPart ? (" on " + _parts + " part(s)") : "") + " so far.");
				}
			}
		}

		private static void Look()
		{
			//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)
			Tables();
			List<Material> list = new List<Material>();
			int num = 0;
			Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>();
			foreach (Renderer val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Scene scene = ((Component)val).gameObject.scene;
				if (!((Scene)(ref scene)).IsValid())
				{
					continue;
				}
				val.GetSharedMaterials(list);
				for (int j = 0; j < list.Count; j++)
				{
					Material val2 = list[j];
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					int instanceID = ((Object)val2).GetInstanceID();
					if (_notOurs.Contains(instanceID) || _copyIds.Contains(instanceID) || _done.ContainsKey(instanceID) || _leftAlone.Contains(instanceID))
					{
						continue;
					}
					string text = IdOf(val2);
					if (text == null)
					{
						_notOurs.Add(instanceID);
					}
					else
					{
						if (!_rows.TryGetValue(text, out var value) || value.pick == "keep" || value.pick == "already")
						{
							continue;
						}
						if (_perPart)
						{
							if (IsKept(((Component)val).transform))
							{
								continue;
							}
							long num2 = ((long)((Object)val).GetInstanceID() << 8) ^ j;
							if (!_queued.Add((int)(num2 ^ (num2 >> 32))))
							{
								continue;
							}
						}
						else if (!_queued.Add(instanceID))
						{
							continue;
						}
						_queue.Enqueue(new Job
						{
							r = val,
							slot = j,
							m = val2,
							id = text
						});
						num++;
					}
				}
			}
			if (!_perPart)
			{
				LookAtLayers();
			}
			if (num > 0 && !_saidRound)
			{
				_saidRound = true;
				Say("Texture look '" + Mode + "': " + num + " of our material(s) found to change; done a few a frame.");
			}
		}

		private static string IdOf(Material m)
		{
			if (_matIds.TryGetValue(((Object)m).GetInstanceID(), out var value))
			{
				return value;
			}
			Texture val = null;
			try
			{
				if (m.HasProperty("_MainTex"))
				{
					val = m.mainTexture;
				}
			}
			catch (Exception)
			{
			}
			if (!((Object)(object)val != (Object)null) || !_texIds.TryGetValue(((Object)val).GetInstanceID(), out value))
			{
				return null;
			}
			return value;
		}

		private static void Do(Job j, string mode)
		{
			//IL_0064: 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_007c: 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_0143: Expected O, but got Unknown
			if ((Object)(object)j.m == (Object)null || !_rows.TryGetValue(j.id, out var value) || !_picks.TryGetValue(value.pick, out var value2))
			{
				return;
			}
			if (!_perPart)
			{
				int instanceID = ((Object)j.m).GetInstanceID();
				if (!_done.ContainsKey(instanceID))
				{
					Material val = new Material(j.m)
					{
						name = ((Object)j.m).name
					};
					if (Apply(j.m, val, value, value2, j.r, mode))
					{
						_done[instanceID] = new Done
						{
							m = j.m,
							snap = val
						};
						_changed++;
					}
					else
					{
						Object.Destroy((Object)(object)val);
						_done[instanceID] = new Done
						{
							m = j.m,
							snap = null
						};
					}
				}
			}
			else
			{
				if ((Object)(object)j.r == (Object)null)
				{
					return;
				}
				if (!_copies.TryGetValue(((Object)j.m).GetInstanceID(), out var value3) || (Object)(object)value3 == (Object)null)
				{
					value3 = new Material(j.m)
					{
						name = ((Object)j.m).name
					};
					if (!Apply(value3, j.m, value, value2, j.r, mode))
					{
						Object.Destroy((Object)(object)value3);
						value3 = null;
						_leftAlone.Add(((Object)j.m).GetInstanceID());
					}
					else
					{
						_changed++;
						_copyIds.Add(((Object)value3).GetInstanceID());
						_copies[((Object)j.m).GetInstanceID()] = value3;
					}
				}
				if (!((Object)(object)value3 == (Object)null))
				{
					Material[] sharedMaterials = j.r.sharedMaterials;
					if (j.slot < sharedMaterials.Length && !((Object)(object)sharedMaterials[j.slot] != (Object)(object)j.m))
					{
						sharedMaterials[j.slot] = value3;
						j.r.sharedMaterials = sharedMaterials;
						_parts++;
						_swaps.Add(new Swap
						{
							r = j.r,
							slot = j.slot,
							was = j.m,
							now = value3
						});
					}
				}
			}
		}

		private static bool Apply(Material t, Material ours, Row row, Pick pick, Renderer r, string mode)
		{
			//IL_0115: 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_0129: 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_02d5: 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_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			Texture val = null;
			try
			{
				if (ours.HasProperty("_MainTex"))
				{
					val = ours.mainTexture;
				}
			}
			catch (Exception)
			{
			}
			if (mode == "Plain")
			{
				Texture2D val2 = (Texture2D)(object)((val is Texture2D) ? val : null);
				if ((Object)(object)val2 == (Object)null)
				{
					return false;
				}
				Texture2D val3 = PlainOf(val2);
				if ((Object)(object)val3 == (Object)null)
				{
					return false;
				}
				t.mainTexture = (Texture)(object)val3;
				if (t.HasProperty("_BumpMap") && (Object)(object)t.GetTexture("_BumpMap") != (Object)null && t.HasProperty("_BumpScale"))
				{
					t.SetFloat("_BumpScale", t.GetFloat("_BumpScale") * 0.5f);
				}
				return true;
			}
			switch (pick.mode)
			{
			case "hide":
			{
				if (!t.HasProperty("_Color"))
				{
					return false;
				}
				Color color2 = t.color;
				color2.a = 0f;
				t.color = color2;
				return true;
			}
			case "flat_material":
			{
				Material val8 = GameMat(pick);
				if ((Object)(object)val8 != (Object)null)
				{
					TurnInto(t, val8);
					NoBumpWithoutTangents(t, r);
					return true;
				}
				Flat(t, pick, val);
				return true;
			}
			case "game_glass":
			{
				Material val5 = GameMat(pick);
				if ((Object)(object)val5 == (Object)null)
				{
					return false;
				}
				TurnInto(t, val5);
				float num = 2.5f;
				t.mainTextureScale = new Vector2(num, num);
				return true;
			}
			case "material_copy":
			{
				Material val6 = GameMat(pick);
				if ((Object)(object)val6 == (Object)null && pick.card)
				{
					Warn(pick, "not found among the game's loaded materials - our own cut-out cards kept");
					return false;
				}
				if ((Object)(object)val6 == (Object)null)
				{
					Flat(t, pick, val);
					return true;
				}
				if (pick.card || (Object)(object)val6.shader == (Object)null || (!(((Object)val6.shader).name == "Standard") && !((Object)val6.shader).name.StartsWith("Ciconia", StringComparison.Ordinal)))
				{
					Texture val7 = (val6.HasProperty("_MainTex") ? val6.mainTexture : null);
					if ((Object)(object)val7 == (Object)null && pick.card)
					{
						return false;
					}
					if ((Object)(object)val7 == (Object)null)
					{
						Flat(t, pick, val);
						return true;
					}
					t.mainTexture = val7;
					ClearMaps(t);
					if (!pick.card)
					{
						Scale(t, r, pick, val7);
					}
					return true;
				}
				TurnInto(t, val6);
				NoBumpWithoutTangents(t, r);
				Scale(t, r, pick, t.mainTexture);
				if (pick.fromOurs && t.HasProperty("_Color"))
				{
					Color color = (row.hasOurs ? row.ours : MeanOf((Texture2D)(object)((val is Texture2D) ? val : null), ours.color));
					color.a = t.color.a;
					t.color = color;
				}
				return true;
			}
			case "texture":
			case "atlas_cut":
			{
				Texture val4 = ((pick.mode == "texture") ? GameTex(pick) : CutOf(pick));
				if ((Object)(object)val4 == (Object)null && pick.card)
				{
					Warn(pick, "not found among the game's loaded pictures - our own cut-out cards kept");
					return false;
				}
				if ((Object)(object)val4 == (Object)null)
				{
					Flat(t, pick, val);
					return true;
				}
				t.mainTexture = val4;
				ClearMaps(t);
				if (!pick.card)
				{
					Scale(t, r, pick, val4);
				}
				return true;
			}
			default:
				return false;
			}
		}

		private static void TurnInto(Material t, Material g)
		{
			string name = ((Object)t).name;
			t.shader = g.shader;
			t.CopyPropertiesFromMaterial(g);
			t.shaderKeywords = g.shaderKeywords;
			t.renderQueue = g.renderQueue;
			((Object)t).name = name;
		}

		private static void NoBumpWithoutTangents(Material t, Renderer r)
		{
			if (t.HasProperty("_BumpMap") && !((Object)(object)t.GetTexture("_BumpMap") == (Object)null))
			{
				bool flag = false;
				try
				{
					MeshFilter val = (((Object)(object)r != (Object)null) ? ((Component)r).GetComponent<MeshFilter>() : null);
					Mesh val2 = (((Object)(object)val != (Object)null) ? val.sharedMesh : null);
					flag = (Object)(object)val2 != (Object)null && val2.isReadable && val2.tangents != null && val2.tangents.Length == val2.vertexCount && val2.vertexCount > 0;
				}
				catch (Exception)
				{
				}
				if (!flag)
				{
					t.SetTexture("_BumpMap", (Texture)null);
					t.DisableKeyword("_NORMALMAP");
				}
			}
		}

		private static void Flat(Material t, Pick pick, Texture ourTex)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0021: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Color val = (pick.hasFlat ? pick.flat : MeanOf((Texture2D)(object)((ourTex is Texture2D) ? ourTex : null), t.color));
			Warn(pick, "not found among the game's loaded " + ((pick.mode == "flat_material" || pick.mode == "material_copy") ? "materials" : "pictures") + " - its flat colour " + Hex(val) + " used instead");
			if (t.HasProperty("_MainTex"))
			{
				t.mainTexture = null;
			}
			ClearMaps(t);
			if (t.HasProperty("_Color"))
			{
				Color color = t.color;
				val.a = ((pick.mode == "flat_material" && pick.hasFlat) ? (pick.flat.a * color.a) : color.a);
				t.color = val;
			}
		}

		private static string Hex(Color c)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return "#" + ColorUtility.ToHtmlStringRGB(c);
		}

		private static void Warn(Pick p, string what)
		{
			if (_warned.Add(p.key))
			{
				Say("Texture look: the game's '" + ((p.mat.Length > 0) ? p.mat : ((p.layer.Length > 0) ? p.layer : p.tex)) + "' (" + p.key + ") " + what + ".");
			}
		}

		private static void ClearMaps(Material t)
		{
			if (t.HasProperty("_BumpMap") && (Object)(object)t.GetTexture("_BumpMap") != (Object)null)
			{
				t.SetTexture("_BumpMap", (Texture)null);
				t.DisableKeyword("_NORMALMAP");
			}
			if (t.HasProperty("_OcclusionMap") && (Object)(object)t.GetTexture("_OcclusionMap") != (Object)null)
			{
				t.SetTexture("_OcclusionMap", (Texture)null);
			}
			if (t.HasProperty("_ParallaxMap") && (Object)(object)t.GetTexture("_ParallaxMap") != (Object)null)
			{
				t.SetTexture("_ParallaxMap", (Texture)null);
				t.DisableKeyword("_PARALLAXMAP");
			}
			if (t.HasProperty("_DetailAlbedoMap") && (Object)(object)t.GetTexture("_DetailAlbedoMap") != (Object)null)
			{
				t.SetTexture("_DetailAlbedoMap", (Texture)null);
				t.DisableKeyword("_DETAIL_MULX2");
			}
		}

		private static void Scale(Material t, Renderer r, Pick pick, Texture gt)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (pick.tile <= 0f)
			{
				return;
			}
			float num = MetresPerUv(r);
			if (!float.IsNaN(num) && !(num <= 0f))
			{
				float num2 = 1f;
				if ((Object)(object)gt != (Object)null && gt.width > 0)
				{
					num2 = (float)gt.height / (float)gt.width;
				}
				t.mainTextureScale = new Vector2(num / pick.tile, num / (pick.tile * Mathf.Max(0.05f, num2)));
				t.mainTextureOffset = Vector2.zero;
			}
		}

		private static float MetresPerUv(Renderer r)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_014d: 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_015c: 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_0166: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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)
			if ((Object)(object)r == (Object)null)
			{
				return float.NaN;
			}
			int instanceID = ((Object)r).GetInstanceID();
			if (_mPerUv.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			value = float.NaN;
			try
			{
				MeshFilter component = ((Component)r).GetComponent<MeshFilter>();
				Mesh val = (((Object)(object)component != (Object)null) ? component.sharedMesh : null);
				if ((Object)(object)val != (Object)null && val.isReadable)
				{
					Vector3[] vertices = val.vertices;
					Vector2[] uv = val.uv;
					int[] triangles = val.triangles;
					if (uv != null && uv.Length == vertices.Length && triangles.Length >= 3)
					{
						Transform transform = ((Component)r).transform;
						int num = triangles.Length / 3;
						int num2 = Mathf.Max(1, num / 160);
						List<float> list = new List<float>();
						for (int i = 0; i < num; i += num2)
						{
							int num3 = triangles[i * 3];
							int num4 = triangles[i * 3 + 1];
							int num5 = triangles[i * 3 + 2];
							Vector3 val2 = transform.TransformVector(vertices[num4] - vertices[num3]);
							Vector3 val3 = transform.TransformVector(vertices[num5] - vertices[num3]);
							Vector3 val4 = Vector3.Cross(val2, val3);
							float magnitude = ((Vector3)(ref val4)).magnitude;
							Vector2 val5 = uv[num4] - uv[num3];
							Vector2 val6 = uv[num5] - uv[num3];
							float num6 = Mathf.Abs(val5.x * val6.y - val5.y * val6.x);
							if (magnitude > 1E-06f && num6 > 1E-09f)
							{
								list.Add(Mathf.Sqrt(magnitude / num6));
							}
						}
						if (list.Count > 0)
						{
							list.Sort();
							value = list[list.Count / 2];
						}
					}
				}
			}
			catch (Exception)
			{
				value = float.NaN;
			}
			_mPerUv[instanceID] = value;
			return value;
		}

		private static Material GameMat(Pick p)
		{
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			if (_matOf.TryGetValue(p.key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if (string.IsNullOrEmpty(p.mat))
			{
				return null;
			}
			if (_gameMats == null || Time.unscaledTime - _gameMatsAt > 30f)
			{
				_gameMatsAt = Time.unscaledTime;
				_gameMats = new Dictionary<string, List<Material>>();
				Material[] array = Resources.FindObjectsOfTypeAll<Material>();
				foreach (Material val in array)
				{
					if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null) && !_copyIds.Contains(((Object)val).GetInstanceID()) && !_done.ContainsKey(((Object)val).GetInstanceID()) && !_matIds.ContainsKey(((Object)val).GetInstanceID()))
					{
						if (!_gameMats.TryGetValue(((Object)val).name, out var value2))
						{
							value2 = (_gameMats[((Object)val).name] = new List<Material>());
						}
						value2.Add(val);
					}
				}
			}
			if (!_gameMats.TryGetValue(p.mat, out var value3))
			{
				return null;
			}
			Material val2 = null;
			float num = float.MaxValue;
			foreach (Material item in value3)
			{
				if ((Object)(object)item == (Object)null || _texIds.ContainsKey((item.HasProperty("_MainTex") && (Object)(object)item.mainTexture != (Object)null) ? ((Object)item.mainTexture).GetInstanceID() : 0))
				{
					continue;
				}
				if (!string.IsNullOrEmpty(p.tex))
				{
					Texture val3 = (item.HasProperty("_MainTex") ? item.mainTexture : null);
					if ((Object)(object)val3 != (Object)null && ((Object)val3).name == p.tex)
					{
						val2 = item;
						break;
					}
					continue;
				}
				if (!p.hasFlat || !item.HasProperty("_Color"))
				{
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = item;
					}
					continue;
				}
				Color color = item.color;
				float num2 = Mathf.Abs(color.r - p.flat.r) + Mathf.Abs(color.g - p.flat.g) + Mathf.Abs(color.b - p.flat.b);
				if (num2 < num)
				{
					num = num2;
					val2 = item;
				}
			}
			if ((Object)(object)val2 != (Object)null && p.hasFlat && string.IsNullOrEmpty(p.tex) && num > 0.1f)
			{
				val2 = null;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				_matOf[p.key] = val2;
				Say("Texture look: " + p.key + " is the game's '" + ((Object)val2).name + "' (" + ((Object)val2.shader).name + ").");
			}
			return val2;
		}

		private static bool LayerApi()
		{
			if (_layerTried)
			{
				return _layerType != null;
			}
			_layerTried = true;
			try
			{
				_layerType = Type.GetType("UnityEngine.TerrainLayer, UnityEngine.TerrainModule");
				if (_layerType != null)
				{
					_layerDiffuse = _layerType.GetProperty("diffuseTexture");
					_layerTile = _layerType.GetProperty("tileSize");
				}
				if (_layerDiffuse == null || _layerTile == null)
				{
					_layerType = null;
				}
			}
			catch (Exception)
			{
				_layerType = null;
			}
			return _layerType != null;
		}

		private static Texture GameTex(Pick p)
		{
			if (_texOf.TryGetValue(p.key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = null;
			if (!string.IsNullOrEmpty(p.layer) && LayerApi())
			{
				try
				{
					Object[] array = Resources.FindObjectsOfTypeAll(_layerType);
					foreach (Object val in array)
					{
						if (val != (Object)null && val.name == p.layer)
						{
							object? value2 = _layerDiffuse.GetValue(val, null);
							value = (Texture)((value2 is Texture) ? value2 : null);
							if ((Object)(object)value != (Object)null)
							{
								break;
							}
						}
					}
				}
				catch (Exception)
				{
					value = null;
				}
			}
			if ((Object)(object)value == (Object)null && !string.IsNullOrEmpty(p.tex))
			{
				Texture2D[] array2 = Resources.FindObjectsOfTypeAll<Texture2D>();
				foreach (Texture2D val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && ((Object)val2).name == p.tex && !_texIds.ContainsKey(((Object)val2).GetInstanceID()) && (p.w == 0 || (((Texture)val2).width == p.w && ((Texture)val2).height == p.h)))
					{
						value = (Texture)(object)val2;
						break;
					}
				}
			}
			if ((Object)(object)value != (Object)null)
			{
				_texOf[p.key] = value;
				Say("Texture look: " + p.key + " is the game's picture '" + ((Object)value).name + "' (" + value.width + " x " + value.height + (string.IsNullOrEmpty(p.layer) ? "" : (", terrain layer '" + p.layer + "'")) + ").");
			}
			return value;
		}

		private static Texture CutOf(Pick p)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0133: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_01cd: 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)
			if (_texOf.TryGetValue(p.key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if (!p.hasUv)
			{
				return null;
			}
			Texture val = null;
			Material val2 = GameMat(p);
			if ((Object)(object)val2 != (Object)null && val2.HasProperty("_MainTex"))
			{
				val = val2.mainTexture;
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			int num = Mathf.RoundToInt(((Rect)(ref p.uv)).width * (float)val.width);
			int num2 = Mathf.RoundToInt(((Rect)(ref p.uv)).height * (float)val.height);
			float num3 = Mathf.Min(1f, 1024f / (float)Mathf.Max(num, num2));
			num = Mathf.Max(16, Mathf.RoundToInt((float)num * num3));
			num2 = Mathf.Max(16, Mathf.RoundToInt((float)num2 * num3));
			RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			Texture2D val4;
			try
			{
				Graphics.Blit(val, temporary, new Vector2(((Rect)(ref p.uv)).width, ((Rect)(ref p.uv)).height), new Vector2(((Rect)(ref p.uv)).x, ((Rect)(ref p.uv)).y));
				RenderTexture.active = temporary;
				Texture2D val3 = new Texture2D(num, num2, (TextureFormat)3, true);
				((Object)val3).name = "texture look " + p.key + " (the game's '" + ((Object)val).name + "')";
				val4 = val3;
				val4.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0, false);
				if (p.turned)
				{
					Color32[] pixels = val4.GetPixels32();
					Color32[] array = (Color32[])(object)new Color32[pixels.Length];
					for (int i = 0; i < num2; i++)
					{
						for (int j = 0; j < num; j++)
						{
							array[j * num2 + i] = pixels[i * num + j];
						}
					}
					Object.Destroy((Object)(object)val4);
					val3 = new Texture2D(num2, num, (TextureFormat)3, true);
					((Object)val3).name = "texture look " + p.key + " (the game's '" + ((Object)val).name + "', turned)";
					val4 = val3;
					val4.SetPixels32(array);
				}
				((Texture)val4).wrapMode = (TextureWrapMode)0;
				((Texture)val4).filterMode = (FilterMode)2;
				((Texture)val4).anisoLevel = 4;
				val4.Apply(true, true);
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
			_texOf[p.key] = (Texture)(object)val4;
			Say("Texture look: " + p.key + " cut from the game's '" + ((Object)val).name + "' (" + ((Texture)val4).width + " x " + ((Texture)val4).height + ").");
			return (Texture)(object)val4;
		}

		private static Texture2D PlainOf(Texture2D src)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: 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)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			if (_plain.TryGetValue(((Object)src).GetInstanceID(), out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			int num = Mathf.Max(4, ((Texture)src).width / 2);
			int num2 = Mathf.Max(4, ((Texture)src).height / 2);
			bool flag = HasAlpha(src.format);
			RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture val = null;
			RenderTexture active = RenderTexture.active;
			try
			{
				((Texture)temporary).wrapMode = (TextureWrapMode)0;
				((Texture)temporary).filterMode = (FilterMode)1;
				Graphics.Blit((Texture)(object)src, temporary);
				if (!flag)
				{
					val = RenderTexture.GetTemporary(Mathf.Max(2, num / 2), Mathf.Max(2, num2 / 2), 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
					((Texture)val).wrapMode = (TextureWrapMode)0;
					((Texture)val).filterMode = (FilterMode)1;
					Graphics.Blit((Texture)(object)temporary, val);
					Graphics.Blit((Texture)(object)val, temporary);
				}
				RenderTexture.active = temporary;
				value = new Texture2D(num, num2, (TextureFormat)(flag ? 4 : 3), true)
				{
					name = ((Object)src).name + " (plain)"
				};
				value.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0, false);
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
				if ((Object)(object)val != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val);
				}
			}
			Color32[] pixels = value.GetPixels32();
			double num3 = 0.0;
			double num4 = 0.0;
			double num5 = 0.0;
			int num6 = 0;
			for (int i = 0; i < pixels.Length; i++)
			{
				if (!flag || pixels[i].a >= 128)
				{
					num3 += (double)(int)pixels[i].r;
					num4 += (double)(int)pixels[i].g;
					num5 += (double)(int)pixels[i].b;
					num6++;
				}
			}
			if (num6 > 0)
			{
				float num7 = (float)(num3 / (double)num6);
				float num8 = (float)(num4 / (double)num6);
				float num9 = (float)(num5 / (double)num6);
				for (int j = 0; j < pixels.Length; j++)
				{
					Color32 val2 = pixels[j];
					float num10 = num7 + ((float)(int)val2.r - num7) * 0.75f;
					float num11 = num8 + ((float)(int)val2.g - num8) * 0.75f;
					float num12 = num9 + ((float)(int)val2.b - num9) * 0.75f;
					float num13 = num10 * 0.299f + num11 * 0.587f + num12 * 0.114f;
					num10 += (num13 - num10) * 0.1f;
					num11 += (num13 - num11) * 0.1f;
					num12 += (num13 - num12) * 0.1f;
					pixels[j] = new Color32(B(num10), B(num11), B(num12), val2.a);
				}
				value.SetPixels32(pixels);
			}
			((Texture)value).wrapModeU = ((Texture)src).wrapModeU;
			((Texture)value).wrapModeV = ((Texture)src).wrapModeV;
			((Texture)value).filterMode = ((Texture)src).filterMode;
			((Texture)value).anisoLevel = ((Texture)src).anisoLevel;
			value.Apply(true, true);
			_plain[((Object)src).GetInstanceID()] = value;
			return value;
		}

		private static byte B(float v)
		{
			return (byte)Mathf.Clamp(Mathf.RoundToInt(v), 0, 255);
		}

		private static bool HasAlpha(TextureFormat f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0012: 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_003f: Expected I4, but got Unknown
			//IL_0004: 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_0008: Invalid comparison between Unknown and I4
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_000a: 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: Invalid comparison between Unknown and I4
			if ((int)f <= 5)
			{
				if (f - 1 > 1 && f - 4 > 1)
				{
					goto IL_0046;
				}
			}
			else
			{
				switch (f - 12)
				{
				default:
					if ((int)f == 25)
					{
						break;
					}
					goto IL_0046;
				case 0:
				case 1:
				case 2:
				case 5:
				case 8:
					break;
				case 3:
				case 4:
				case 6:
				case 7:
					goto IL_0046;
				}
			}
			return true;
			IL_0046:
			return false;
		}

		private static Color MeanOf(Texture2D tex, Color tint)
		{
			//IL_00d2: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_0032: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//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_0072: 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_0079: 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_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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00c8: 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)
			if ((Object)(object)tex == (Object)null)
			{
				return tint;
			}
			RenderTexture temporary = RenderTexture.GetTemporary(4, 4, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			try
			{
				Graphics.Blit((Texture)(object)tex, temporary);
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D(4, 4, (TextureFormat)3, false);
				val.ReadPixels(new Rect(0f, 0f, 4f, 4f), 0, 0, false);
				Color[] pixels = val.GetPixels();
				Object.Destroy((Object)val);
				Color val2 = Color.black;
				Color[] array = pixels;
				foreach (Color val3 in array)
				{
					val2 += val3;
				}
				val2 /= (float)pixels.Length;
				return new Color(val2.r * tint.r, val2.g * tint.g, val2.b * tint.b, tint.a);
			}
			catch (Exception)
			{
				return tint;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		private static void LookAtLayers()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0100: 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_01d0: 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)
			if (_texIds.Count == 0 || !LayerApi())
			{
				return;
			}
			Object[] array = Resources.FindObjectsOfTypeAll(_layerType);
			foreach (Object val in array)
			{
				if (val == (Object)null || _layerSeen.Contains(val.GetInstanceID()))
				{
					continue;
				}
				object? value = _layerDiffuse.GetValue(val, null);
				Texture val2 = (Texture)((value is Texture) ? value : null);
				if ((Object)(object)val2 == (Object)null || !_texIds.TryGetValue(((Object)val2).GetInstanceID(), out var value2) || !_rows.TryGetValue(value2, out var value3) || !_picks.TryGetValue(value3.pick, out var value4) || value3.pick == "keep" || value3.pick == "already")
				{
					continue;
				}
				_layerSeen.Add(val.GetInstanceID());
				Vector2 val3 = (Vector2)_layerTile.GetValue(val, null);
				Texture val4 = null;
				Vector2 val5 = val3;
				if (Mode == "Plain")
				{
					Texture2D val6 = (Texture2D)(object)((val2 is Texture2D) ? val2 : null);
					if ((Object)(object)val6 != (Object)null)
					{
						val4 = (Texture)(object)PlainOf(val6);
					}
				}
				else if (value4.mode == "texture" || value4.mode == "atlas_cut")
				{
					val4 = ((value4.mode == "texture") ? GameTex(value4) : CutOf(value4));
					if ((Object)(object)val4 != (Object)null && value4.tile > 0f)
					{
						((Vector2)(ref val5))..ctor(value4.tile, value4.tile);
					}
				}
				if (!((Object)(object)val4 == (Object)null))
				{
					_layers.Add(new LayerWas
					{
						layer = val,
						tex = val2,
						tile = val3
					});
					_layerDiffuse.SetValue(val, val4, null);
					_layerTile.SetValue(val, val5, null);
					_changed++;
				}
			}
		}

		private static void PutBack()
		{
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			_queue.Clear();
			_queued.Clear();
			_saidRound = false;
			int num = 0;
			foreach (Done value in _done.Values)
			{
				if (!((Object)(object)value.m == (Object)null) && !((Object)(object)value.snap == (Object)null))
				{
					try
					{
						string name = ((Object)value.snap).name;
						value.m.shader = value.snap.shader;
						value.m.CopyPropertiesFromMaterial(value.snap);
						value.m.shaderKeywords = value.snap.shaderKeywords;
						value.m.renderQueue = value.snap.renderQueue;
						((Object)value.m).name = name;
						num++;
					}
					catch (Exception)
					{
					}
					Object.Destroy((Object)(object)value.snap);
				}
			}
			_done.Clear();
			foreach (Swap swap in _swaps)
			{
				if ((Object)(object)swap.r == (Object)null || (Object)(object)swap.was == (Object)null)
				{
					continue;
				}
				try
				{
					Material[] sharedMaterials = swap.r.sharedMaterials;
					if (swap.slot < sharedMaterials.Length && (Object)(object)sharedMaterials[swap.slot] == (Object)(object)swap.now)
					{
						sharedMaterials[swap.slot] = swap.was;
						swap.r.sharedMaterials = sharedMaterials;
						num++;
					}
				}
				catch (Exception)
				{
				}
			}
			_swaps.Clear();
			foreach (Material value2 in _copies.Values)
			{
				if ((Object)(object)value2 != (Object)null)
				{
					Object.Destroy((Object)(object)value2);
				}
			}
			_copies.Clear();
			_copyIds.Clear();
			_notOurs.Clear();
			_leftAlone.Clear();
			_mPerUv.Clear();
			foreach (LayerWas layer in _layers)
			{
				if (!(layer.layer == (Object)null))
				{
					try
					{
						_layerDiffuse.SetValue(layer.layer, layer.tex, null);
						_layerTile.SetValue(layer.layer, layer.tile, null);
						num++;
					}
					catch (Exception)
					{
					}
				}
			}
			_layers.Clear();
			_layerSeen.Clear();
			_changed = 0;
			_parts = 0;
			if (num > 0)
			{
				Say("Texture look: " + num + " material(s) and part(s) put back as made.");
			}
		}
	}
	internal sealed class TextureLookRunner : MonoBehaviour
	{
		private int _faults;

		private void Update()
		{
			try
			{
				TextureLook.Tick();
			}
			catch (Exception ex)
			{
				if (_faults++ < 3)
				{
					Debug.LogWarning((object)("Texture look: " + ex.Message));
				}
			}
		}
	}
}
namespace SailwindProvisions
{
	internal static class Provisions
	{
		internal struct FoodKind
		{
			public string name;

			public string crate;

			public string donor;

			public int hint;

			public int piece;

			public int pieces;

			public int of;
		}

		internal sealed class Mk
		{
			public readonly List<Vector3> v = new List<Vector3>();

			public readonly List<Vector3> n = new List<Vector3>();

			public readonly List<Vector2> uv = new List<Vector2>();

			public readonly List<int> t = new List<int>();

			public int Add(Vector3 p, Vector3 nrm, Vector2 u)
			{
				//IL_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references)
				v.Add(p);
				n.Add(((Vector3)(ref nrm)).normalized);
				uv.Add(u);
				return v.Count - 1;
			}

			public void Tri(int a, int b, int c)
			{
				//IL_0007: 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_0024: 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_003a: 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)
				//IL_004f: 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_0063: 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_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)
				Vector3 val = Vector3.Cross(v[b] - v[a], v[c] - v[a]);
				if (!(((Vector3)(ref val)).sqrMagnitude < 1E-14f))
				{
					if (Vector3.Dot(val, n[a] + n[b] + n[c]) >= 0f)
					{
						t.Add(a);
						t.Add(b);
						t.Add(c);
					}
					else
					{
						t.Add(a);
						t.Add(c);
						t.Add(b);
					}
				}
			}

			public void Quad(int a, int b, int c, int d)
			{
				Tri(a, b, c);
				Tri(a, c, d);
			}

			public Mesh Mesh(string name)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_003b: 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_004f: Expected O, but got Unknown
				Mesh val = new Mesh
				{
					name = "sailwind farming " + name
				};
				val.SetVertices(v);
				val.SetNormals(n);
				val.SetUVs(0, uv);
				val.SetTriangles(t, 0);
				val.RecalculateBounds();
				return val;
			}
		}

		internal const string VittlesGuid = "com.dixiecapt.sailwind.vittles";

		internal static ManualLogSource Log;

		internal static string Host = "Provisions";

		internal static bool Armed;

		internal static bool Following;

		private static Func<int, GameObject> _leadTemplate;

		private static Func<GameObject, int> _leadKindOf;

		private static Func<int, int> _leadDonor;

		internal static readonly float[] CabbageData = new float[3948]
		{
			-0.0844f, 0.0533f, -0.0358f, -0.748f, -0.655f, 0.106f, 1f, -0.0466f, 0.0126f, -0.0207f,
			-0.748f, -0.655f, 0.106f, 1f, -0.0389f, 0.0126f, 0.0343f, -0.748f, -0.655f, 0.106f,
			1f, -0.0855f, 0.1585f, -0.0332f, -0.964f, 0.226f, 0.137f, 1f, -0.0983f, 0.1089f,
			-0.0414f, -0.964f, 0.226f, 0.137f, 1f, -0.0827f, 0.1089f, 0.0686f, -0.964f, 0.226f,
			0.137f, 1f, -0.0631f, 0.1992f, -0.0143f, -0.475f, 0.877f, 0.067f, 1f, -0.0553f,
			0.1992f, 0.0407f, -0.475f, 0.877f, 0.067f, 1f, -0.0344f, 0.213f, 0.0085f, -0.475f,
			0.877f, 0.067f, 1f, 0.005f, 0f, -0f, -0.25f, -0.968f, 0.035f, 1f,
			-0.0389f, 0.0126f, 0.0343f, -0.25f, -0.968f, 0.035f, 1f, -0.0466f, 0.0126f, -0.0207f,
			-0.25f, -0.968f, 0.035f, 1f, -0.0983f, 0.1089f, -0.0414f, -0.964f, -0.226f, 0.137f,
			1f, -0.0844f, 0.0533f, -0.0358f, -0.964f, -0.226f, 0.137f, 1f, -0.0709f, 0.0533f,
			0.0594f, -0.964f, -0.226f, 0.137f, 1f, -0.0631f, 0.1992f, -0.0143f, -0.893f, 0.433f,
			0.126f, 1f, -0.0855f, 0.1585f, -0.0332f, -0.893f, 0.433f, 0.126f, 1f, -0.072f,
			0.1585f, 0.062f, -0.893f, 0.433f, 0.126f, 1f, -0.0553f, 0.1992f, 0.0407f, -0.087f,
			0.935f, 0.344f, 1f, 0.0117f, 0.1992f, 0.0576f, -0.087f, 0.935f, 0.344f, 1f,
			-0.0344f, 0.213f, 0.0085f, -0.087f, 0.935f, 0.344f, 1f, 0.005f, 0f, -0f,
			-0.094f, -0.968f, 0.235f, 1f, 0.0128f, 0.0126f, 0.055f, -0.094f, -0.968f, 0.235f,
			1f, -0.0389f, 0.0126f, 0.0343f, -0.094f, -0.968f, 0.235f, 1f, -0.0827f, 0.1089f,
			0.0686f, -0.362f, -0.226f, 0.904f, 1f, -0.0709f, 0.0533f, 0.0594f, -0.362f, -0.226f,
			0.904f, 1f, 0.0185f, 0.0533f, 0.0953f, -0.362f, -0.226f, 0.904f, 1f, -0.0709f,
			0.0533f, 0.0594f, -0.281f, -0.655f, 0.702f, 1f, -0.0389f, 0.0126f, 0.0343f, -0.281f,
			-0.655f, 0.702f, 1f, 0.0128f, 0.0126f, 0.055f, -0.281f, -0.655f, 0.702f, 1f,
			-0.0827f, 0.1089f, 0.0686f, -0.364f, 0.2f, 0.91f, 1f, 0.0206f, 0.1089f, 0.11f,
			-0.364f, 0.2f, 0.91f, 1f, 0.0174f, 0.1585f, 0.0978f, -0.364f, 0.2f, 0.91f,
			1f, -0.072f, 0.1585f, 0.062f, -0.241f, 0.581f, 0.777f, 1f, 0.0174f, 0.1585f,
			0.0978f, -0.281f, 0.655f, 0.702f, 1f, 0.0117f, 0.1992f, 0.0576f, -0.261f, 0.618f,
			0.741f, 1f, -0.0106f, 0.1089f, -0.11f, -0.601f, -0.226f, -0.767f, 1f, -0.0085f,
			0.0533f, -0.0953f, -0.601f, -0.226f, -0.767f, 1f, -0.0844f, 0.0533f, -0.0358f, -0.601f,
			-0.226f, -0.767f, 1f, -0.0209f, 0.1992f, -0.0554f, -0.55f, 0.514f, -0.658f, 1f,
			-0.0096f, 0.1585f, -0.0927f, -0.54f, 0.481f, -0.69f, 1f, -0.0855f, 0.1585f, -0.0332f,
			-0.557f, 0.541f, -0.63f, 1f, -0.0028f, 0.0126f, -0.055f, -0.466f, -0.654f, -0.595f,
			1f, -0.0466f, 0.0126f, -0.0207f, -0.466f, -0.654f, -0.595f, 1f, -0.0844f, 0.0533f,
			-0.0358f, -0.466f, -0.654f, -0.595f, 1f, -0.0096f, 0.1585f, -0.0927f, -0.592f, 0.277f,
			-0.757f, 1f, -0.0106f, 0.1089f, -0.11f, -0.592f, 0.277f, -0.757f, 1f, -0.0983f,
			0.1089f, -0.0414f, -0.592f, 0.277f, -0.757f, 1f, -0.0209f, 0.1992f, -0.0554f, -0.248f,
			0.935f, -0.254f, 1f, -0.0631f, 0.1992f, -0.0143f, -0.248f, 0.935f, -0.254f, 1f,
			-0.0344f, 0.213f, 0.0085f, -0.248f, 0.935f, -0.254f, 1f, 0.005f, 0f, -0f,
			-0.156f, -0.967f, -0.199f, 1f, -0.0466f, 0.0126f, -0.0207f, -0.156f, -0.967f, -0.199f,
			1f, -0.0028f, 0.0126f, -0.055f, -0.156f, -0.967f, -0.199f, 1f, 0.005f, 0f,
			-0f, 0.075f, -0.97f, -0.233f, 1f, -0.0028f, 0.0126f, -0.055f, 0.075f, -0.97f,
			-0.233f, 1f, 0.0404f, 0.0109f, -0.0338f, 0.075f, -0.97f, -0.233f, 1f, -0.0028f,
			0.0126f, -0.055f, 0.315f, -0.645f, -0.696f, 1f, -0.0085f, 0.0533f, -0.0953f, 0.315f,
			-0.645f, -0.696f, 1f, 0.0404f, 0.0109f, -0.0338f, 0.315f, -0.645f, -0.696f, 1f,
			-0.0844f, 0.0533f, -0.0358f, -0.748f, -0.655f, 0.106f, 1f, -0.0389f, 0.0126f, 0.0343f,
			-0.748f, -0.655f, 0.106f, 1f, -0.0709f,