Decompiled source of DLH3VR v1.3.0
DoomLoader.dll
Decompiled 5 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DoomLoader.Doom; using DoomLoader.Unity; using FistVR; using HarmonyLib; using Microsoft.CodeAnalysis; using Microsoft.Win32; using Sodalite; using Sodalite.Api; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DoomLoader { [BepInPlugin("local.doomloader", "DLH3VR", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("h3vr.exe")] public class Plugin : BaseUnityPlugin { private sealed class WadChoice { public string Iwad; public string Pwad; public string Label; public List<string> Maps; } public const string Guid = "local.doomloader"; public const string Version = "1.3.0"; private ConfigEntry<string> _wadPath; private ConfigEntry<string> _pwadPath; private ConfigEntry<string> _wadFolder; private WristMenuButton _wadButton; private ConfigEntry<string> _mapName; private ConfigEntry<float> _scale; private ConfigEntry<float> _originHeight; private ConfigEntry<float> _originSide; private ConfigEntry<int> _brightness; private ConfigEntry<KeyboardShortcut> _loadKey; private ConfigEntry<string> _firstScene; private ConfigEntry<int> _skill; private WristMenuButton _skillButton; private bool _firstLoadHandled; private string _pendingMap; private ConfigEntry<bool> _requireKeys; private ConfigEntry<bool> _noPostFx; private ConfigEntry<bool> _musicOn; private ConfigEntry<string> _soundFontPath; private ConfigEntry<float> _musicVolume; private MusicPlayer _music; private bool _soundFontFailed; private WristMenuButton _musicButton; private AmmoSystem _ammo; private ConfigEntry<string> _pistolIds; private ConfigEntry<string> _shotgunIds; private ConfigEntry<string> _chaingunIds; private ConfigEntry<string> _superShotgunIds; private ConfigEntry<string> _chaingunMags; private ConfigEntry<string> _rocketIds; private ConfigEntry<string> _plasmaIds; private ConfigEntry<string> _chainsawIds; private ConfigEntry<string> _bfgIds; private ConfigEntry<bool> _deathRestart; private readonly Dictionary<int, ConfigEntry<string>> _powerupIds = new Dictionary<int, ConfigEntry<string>>(); private PowerupSystem _powerups; private string _deathMap; private float _deadSince; private bool _wasDead; private bool _broughtBack; private ConfigEntry<RandomWeapons> _randomWeapons; private ConfigEntry<bool> _randomModded; private ConfigEntry<string> _randomSets; private WristMenuButton _randomButton; private WristMenuButton _warpButton; private string _warpTarget; private LineTriggers _lines; private ConfigEntry<string> _pouchOffset; private ConfigEntry<string> _magOverrides; private ConfigEntry<bool> _monstersOn; private readonly Dictionary<int, ConfigEntry<string>> _monsterSosigs = new Dictionary<int, ConfigEntry<string>>(); private MonsterManager _monsters; private ConfigEntry<int> _maxSosigs; private ConfigEntry<float> _weaponDropChance; private ConfigEntry<bool> _preferLoaders; private ConfigEntry<MonsterStyle> _monsterStyle; private ConfigEntry<float> _classicDamage; private ConfigEntry<float> _classicCurve; private ConfigEntry<float> _classicExplosive; private ConfigEntry<float> _classicMelee; private WristMenuButton _styleButton; private SpriteIndex _sprites; private Dictionary<int, DoorController> _doors = new Dictionary<int, DoorController>(); private WadFile _wad; private DoomTextures _textures; private DoomPalette _palette; private GameObject _level; private LevelGeometry _geo; private WristMenuButton _loadButton; private WristMenuButton _scaleButton; private DoomMap _map; private LevelGeometryBuilder _builder; private PostFxSuppressor _postFx; private static readonly int[] ScalePresets = new int[6] { 28, 32, 36, 40, 44, 48 }; private string _foundWad; private static readonly string[] IwadOrder = new string[7] { "DOOM2.WAD", "DOOM.WAD", "TNT.WAD", "PLUTONIA.WAD", "freedoom2.wad", "freedoom1.wad", "DOOM1.WAD" }; private List<string> _steamWads; private string _appliedSets; private bool _appliedModded; private bool _appliedPosed; private int _appliedPoseVersion = -1; private ConfigEntry<bool> _posedOnly; private WristMenuButton _posedButton; private bool _exiting; private float _nextBossCheck; private string _statsMap; private float _levelStart; private readonly HashSet<int> _secretsFound = new HashSet<int>(); private readonly List<string> _episodeVisited = new List<string>(); private IntermissionScreen _intermission; private ConfigEntry<bool> _intermissionOn; public static string DataFolder => Path.Combine(Paths.ConfigPath, "DLH3VR"); private string WadPath { get { string text = _wadPath.Value.Trim(); if (text.Length > 0) { return text; } if (_foundWad == null || !File.Exists(_foundWad)) { _foundWad = FindWad(); } return _foundWad ?? Path.Combine(DataFolder, "DOOM2.WAD"); } } private List<string> SteamWads { get { if (_steamWads != null) { return _steamWads; } _steamWads = new List<string>(); try { _steamWads = SteamLocator.FindWads(out var how); ((BaseUnityPlugin)this).Logger.LogInfo((object)((_steamWads.Count > 0) ? ("Found " + _steamWads.Count + " WAD(s) from " + how + ": " + string.Join(", ", _steamWads.ConvertAll((string f) => Path.GetFileName(f)).ToArray()) + ".") : ("Steam check: " + how + "."))); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Steam check failed: " + ex.Message)); } return _steamWads; } } private string SoundFontPath { get { string text = _soundFontPath.Value.Trim(); if (text.Length > 0) { return text; } if (!Directory.Exists(DataFolder)) { return ""; } string[] files = Directory.GetFiles(DataFolder, "*.sf2"); if (files.Length == 0) { return Path.Combine(DataFolder, "(no .sf2 here)"); } return files[0]; } } private void Awake() { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_0acc: Unknown result type (might be due to invalid IL or missing references) //IL_0ad2: Expected O, but got Unknown //IL_0873: Unknown result type (might be due to invalid IL or missing references) //IL_087d: Expected O, but got Unknown //IL_08f8: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Expected O, but got Unknown //IL_0a0d: Unknown result type (might be due to invalid IL or missing references) //IL_0a17: Expected O, but got Unknown _wadPath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "WadPath", "", "Path to your DOOM.WAD / DOOM2.WAD / FREEDOOM*.WAD (not distributed with this mod). Empty = a WAD in BepInEx/config/DLH3VR (DOOM2.WAD, then DOOM.WAD, then Freedoom, else the first IWAD there), else your Steam copy of DOOM II / Doom / Final Doom."); _pwadPath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Pwad", "", "Optional custom map WAD (PWAD) layered on top of WadPath; its maps, textures, sprites, sounds and music replace the base WAD's. Empty = none. Set by the wrist menu's WAD button."); _wadFolder = ((BaseUnityPlugin)this).Config.Bind<string>("General", "WadFolder", "", "Folder the wrist menu's WAD button cycles through (and its subfolders). Empty = the folder WadPath is in. IWADs play on their own; PWADs (map packs) are paired with a matching IWAD (DOOM II-style maps with DOOM2.WAD, ExMy maps with DOOM.WAD)."); _mapName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Map", "E1M1", "Map to load (ExMy or MAPxx)."); _scale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MetersPerUnit", 1f / 32f, "World scale. 1/32 makes the 56-unit Doom player 1.75 m tall."); _originHeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OriginHeight", 500f, "Height (m) at which the Doom map is built, to keep it clear of the host scene."); _originSide = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OriginOffset", 3000f, "How far (m) east and north of the host scene the Doom map is built. Keeps the level's NavMesh well away from the scene's own, which otherwise captured monsters (they spawned under the map or vanished)."); _brightness = ((BaseUnityPlugin)this).Config.Bind<int>("Visuals", "BrightnessBoost", 8, "Colormap steps to brighten sector lighting by (0 = Doom's far-distance darkness, 16+ = nearly fullbright)."); _firstScene = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FirstLoadScene", "Grillhouse_2Story", "Scene to switch to the first time you press Load in a session (the map is built once it has loaded). Empty = never switch."); SceneManager.sceneLoaded += OnSceneLoaded; _loadKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Debug", "LoadKey", new KeyboardShortcut((KeyCode)289, (KeyCode[])(object)new KeyCode[0]), "Desktop hotkey to load the configured map."); _skill = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "Skill", 3, new ConfigDescription("Difficulty, Doom's numbering: 1 I'm Too Young To Die, 2 Hey Not Too Rough, 3 Hurt Me Plenty, 4 Ultra-Violence, 5 Nightmare. Decides which monsters and items appear; 1 and 5 double ammo pickups.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), new object[0])); ThingFlags.Skill = _skill.Value; _requireKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "RequireKeys", true, "Colored-key doors and switches need the matching keycard or skull key, as in Doom. Keys are kept for the current level only."); _noPostFx = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "DisableGameColorGrading", true, "Turn off H3VR's color grading / tonemapping / bloom while a Doom level is loaded, so the WAD palette shows as-is."); _postFx = new PostFxSuppressor(((BaseUnityPlugin)this).Logger); _musicOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Music", "Enabled", true, "Play the map's music (MUS/MIDI from the WAD) through a SoundFont."); _soundFontPath = ((BaseUnityPlugin)this).Config.Bind<string>("Music", "SoundFont", "", "General MIDI .sf2 used to play the music (not distributed with this mod). Empty = the first .sf2 in BepInEx/config/DLH3VR. No SoundFont = no music."); EnsureDataFolder(); _pistolIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "StartingPistol", "M9A1,M9A3,Beretta92FS", "H3VR item IDs to try (in order) for the starting pistol."); _shotgunIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "Shotgun", "I37Shorty", "H3VR item IDs to try for Doom's shotgun (thing 2001): the Ithaca 37 Shorty pump-action by default. If none exist, a pump-action named 'I37Shorty' is searched for."); _superShotgunIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "SuperShotgun", "BreakActionShorty", "H3VR item IDs to try for DOOM II's super shotgun (thing 82): the Break Action Shorty by default (else a break-action named 'Shorty'). Picking it up gives 8 shells."); _chaingunIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "Chaingun", "SpectreM4", "H3VR item IDs to try for Doom's chaingun (thing 2002): the Spectre M4 by default (else any firearm with 'Spectre' in its name). Picking it up gives 20 bullets; the pouch hands out its magazines from your bullets."); _chaingunMags = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "ChaingunMagazine", "", "Magazines the pouch hands out for the chaingun, first that fits wins. Empty = the compatible magazine closest to 50 rounds."); _rocketIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "RocketLauncher", "RPG7", "H3VR item IDs to try for Doom's rocket launcher (thing 2003): the RPG-7 by default. Picking it up gives 2 rockets; the pouch hands out one rocket at a time."); _plasmaIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "PlasmaRifle", "AKM", "H3VR item IDs to try for Doom's plasma rifle (thing 2004): the AKM by default. Picking it up gives 40 cells; it draws from cells, 30-round magazines."); _chainsawIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "Chainsaw", "Chainsaw", "H3VR item IDs to try for Doom's chainsaw (thing 2005): H3VR's own power-tool chainsaw by default. Any melee item works."); _bfgIds = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "BFG", "HiroEnkiYTRailgun", "H3VR item IDs to try for Doom's BFG 9000 (thing 2006): a railgun by default (else any firearm with 'Railgun' in its name). It draws 40 cells per round, like the BFG's 40 cells a shot; picking it up gives 40 cells."); _deathRestart = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "RestartOnDeath", true, "Doom rules when you die in a Doom level: you lose your weapons, ammo, armor and keys, and the level restarts from a pistol start."); foreach (PowerupDef item in PowerupDef.All) { _powerupIds[item.DoomType] = ((BaseUnityPlugin)this).Config.Bind<string>("Powerups", item.Name, "auto", "Picatinny rail attachment(s) standing in for Doom's " + item.Message + " (thing " + item.DoomType + "); mount it on a gun to use the powerup. \"auto\" = the first " + string.Join(" / ", item.Features) + " attachment (a random one when Randomize is on). Or H3VR item IDs, first that exists wins."); } _randomWeapons = ((BaseUnityPlugin)this).Config.Bind<RandomWeapons>("Weapons", "Randomize", RandomWeapons.Off, "Off = the fixed guns (StartingPistol / Shotgun / Chaingun). PerGame = one random gun per Doom weapon slot each pistol start. PerPickup = every gun placed on the map is rolled separately. Pools: Pistol = semi-auto handguns, Shotgun = non-break-action shotguns, Super shotgun = break-action shotguns, Chaingun = full-auto SMGs/rifles/LMGs and sniper rifles, Rocket launcher = launchers and anti-materiel rifles, Plasma rifle = battle rifles, BFG = bulky machine guns (1 cell per round), Chainsaw = melee weapons (no shields). Powerup attachments are randomised too."); _randomModded = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "IncludeModdedGuns", false, "Let random weapons include guns added by mods."); _posedOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "PosedWeaponsOnly", false, "Only spawn weapons that have hand poses in the GlovesTan3 PoseKit (the pose files in BepInEx/config/GlovesTan3Poses, matched by item ID like the PoseKit does; with its auto copy on, similarly named guns count too). Random picks come only from posed guns of the slot's category (this overrides Sets and IncludeModdedGuns); a configured gun without poses is swapped for a posed one of the same kind. A category with no posed guns falls back to the usual gun. Also on the DOOM Options wrist page."); _randomSets = ((BaseUnityPlugin)this).Config.Bind<string>("Weapons", "Sets", "Real,GroundedFictional", "H3VR item sets random weapons may come from: Real, GroundedFictional, SciFiFictional, Meme, MeatFortress, Holiday, TNH, NonCombat, Sulfur."); _lines = ((Component)this).gameObject.AddComponent<LineTriggers>(); _lines.Log = ((BaseUnityPlugin)this).Logger; _lines.OnExit = delegate(bool secret) { ((MonoBehaviour)this).StartCoroutine(ExitLevel(secret)); }; _lines.OnTeleport = TeleportTo; _lines.Monsters = () => (!((Object)(object)_monsters != (Object)null)) ? new List<MonsterManager.MonsterHandle>() : _monsters.Handles(); _pouchOffset = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "PouchOffset", "0,-0.4,0.18", "Ammo pouch position relative to your head (meters: right,up,forward). Default = lower chest. Grab it with an empty hand to pull a magazine; drop magazines into it to return rounds."); _magOverrides = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "MagazineOverrides", "", "Force a magazine per gun: GunItemID=MagazineItemID, comma separated (e.g. M9A1=MagazineM9A3). Candidates are listed in the log."); _preferLoaders = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "PreferLoaders", true, "Guns without a box magazine get a loader from the pouch when H3VR pairs one with them: a speedloader or removable chamber / cylinder (revolvers, the P11's barrel packs, Jackhammer and P6 cylinders), else a stripper clip or en-bloc clip (Mosin, K98k, Lee-Enfield, M1 Garand...). Filled from your reserve; drop it back in the pouch to return its rounds. Off = one loose round at a time."); _ammo = ((Component)this).gameObject.AddComponent<AmmoSystem>(); _ammo.Log = ((BaseUnityPlugin)this).Logger; _ammo.Catalog = new WeaponCatalog { Log = ((BaseUnityPlugin)this).Logger }; try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); _ammo.TextFont = BitmapFontData.Load(Path.Combine(directoryName, "DoomFont.png"), Path.Combine(directoryName, "DoomFont.txt")); ((BaseUnityPlugin)this).Logger.LogInfo((object)((_ammo.TextFont != null) ? ("Doom font loaded (" + _ammo.TextFont.Glyphs.Count + " glyphs).") : "Doom font not found next to the DLL; using Arial.")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Doom font failed to load, using Arial: " + ex.Message)); } _monstersOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "Enabled", true, "Spawn Sosigs in place of Doom monsters."); foreach (MonsterDef item2 in MonsterDef.All) { string text = ((item2.Weapons == WeaponClass.Any) ? "" : (" Must be " + item2.Weapons.ToString().ToLowerInvariant() + "-only.")); _monsterSosigs[item2.DoomType] = ((BaseUnityPlugin)this).Config.Bind<string>("Monsters", item2.Name, "auto", "SosigEnemyID(s) for the " + item2.Name + " (Doom type " + item2.DoomType + "), first usable one wins." + text + " Toughness x" + item2.Toughness + (item2.Invisible ? ", invisible" : "") + ". \"auto\" = " + string.Join(", ", item2.Auto) + ". Empty = don't spawn."); } _maxSosigs = ((BaseUnityPlugin)this).Config.Bind<int>("Monsters", "MaxSosigs", 60, "Most Sosigs spawned per map (the nearest to you first). Some Doom maps have 100+ monsters; 0 = no limit."); _weaponDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "WeaponDropChance", 0.25f, new ConfigDescription("Chance that a zombieman, shotgun guy, chaingunner or SS also drops its gun (the Pistol / Shotgun / Chaingun slot's gun, random when Randomize is on), on top of its usual ammo drop. The gun comes empty.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); _monsterStyle = ((BaseUnityPlugin)this).Config.Bind<MonsterStyle>("Monsters", "Style", MonsterStyle.Classic, "Classic (default) = the original Doom monsters. Sosigs = Doom monsters played by H3VR Sosigs. Classic = the original Doom monsters: their sprites, health, speed, attacks (bullets, fireballs, rockets, bites) and sounds, waking up when they see you or hear your gunfire. Covers every DOOM / DOOM II monster, including the arch-vile's resurrections and the pain elemental's lost souls. Also on the wrist menu."); _classicDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "ClassicDamage9mm", 10f, "Classic monsters: Doom damage of one 9mm hit (Doom's pistol does 5-15, average 10). Everything else scales from it by hit energy. Raise to make all guns stronger."); _classicCurve = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "ClassicDamageCurve", 0.5f, new ConfigDescription("How damage grows with a round's energy. 0.5 (square root): buckshot ~7 a pellet (a full blast ≈ Doom's shotgun, 70), 5.56 ~18, 7.62x39 ~20, 7.62 NATO ~26, .50 BMG ~60. 1 = proportional to energy (rifles get very strong: 7.62 NATO ~70, .50 BMG ~360).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1.5f), new object[0])); _classicExplosive = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "ClassicExplosiveMultiplier", 3f, "Classic monsters: extra multiplier for explosions (rockets, grenades)."); _classicMelee = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "ClassicMeleeMultiplier", 1f, "Classic monsters: extra multiplier for melee hits (berserk adds x10 on top)."); _monsters = ((Component)this).gameObject.AddComponent<MonsterManager>(); _monsters.Log = ((BaseUnityPlugin)this).Logger; _monsters.Ammo = _ammo; FloorMover.Settled += _monsters.OnMoverSettled; FloorMover.Started += _monsters.OnMoverStarted; DoorController.Changed += _monsters.OnDoorChanged; _monsters.CeilingOf = (int sec) => (!_doors.TryGetValue(sec, out var value) || !((Object)(object)value != (Object)null)) ? ((_map == null) ? 0f : ((float)_map.Sectors[sec].Ceiling)) : value.CurrentCeiling; _musicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Music", "Volume", 0.5f, new ConfigDescription("Music volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); _intermission = ((Component)this).gameObject.AddComponent<IntermissionScreen>(); _intermissionOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Intermission", true, "Show Doom's end-of-level screen when you exit: the level name and FINISHED, your KILLS / ITEMS / SECRET percentages and TIME against PAR counting up, then ENTERING the next level (on DOOM's episode maps with splats and a blinking 'you are here'), with the intermission music. Pull a trigger to skip the count / move on. Off = straight to the next level."); _powerups = ((Component)this).gameObject.AddComponent<PowerupSystem>(); _powerups.Log = ((BaseUnityPlugin)this).Logger; _powerups.Ammo = _ammo; _powerups.OnFloorExit = delegate { ((MonoBehaviour)this).StartCoroutine(ExitLevel(secret: false)); }; try { BuildWristMenu(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Wrist menu setup failed: " + ex2)); } Harmony val = new Harmony("local.doomloader"); SosigInitWatch.Log = ((BaseUnityPlugin)this).Logger; Type[] array = new Type[4] { typeof(ArmorPatch), typeof(InvisibilityPatch), typeof(BerserkPatch), typeof(SosigInitWatch) }; foreach (Type type in array) { try { val.PatchAll(type); } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("Patch " + type.Name + " failed: " + ex3.Message)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("DLH3VR 1.3.0 ready. WAD: " + WadPath)); } private void BuildWristMenu() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown WristMenuSectionProxy obj = WristMenuAPI.CreateSection("DOOM Levels"); _wadButton = new WristMenuButton(WadLabel(), (ButtonClickEvent)delegate { CycleWad(); }); obj.Buttons.Add(_wadButton); _loadButton = new WristMenuButton("Load " + _mapName.Value, (ButtonClickEvent)delegate { LoadMap(_mapName.Value); }); obj.Buttons.Add(_loadButton); obj.Buttons.Add(new WristMenuButton("Next map", (ButtonClickEvent)delegate { LoadMap(NextMap(1)); })); obj.Buttons.Add(new WristMenuButton("Prev map", (ButtonClickEvent)delegate { LoadMap(NextMap(-1)); })); obj.Buttons.Add(new WristMenuButton("Back to start", (ButtonClickEvent)delegate { TeleportToStart(); })); obj.Buttons.Add(new WristMenuButton("New game (pistol start)", (ButtonClickEvent)delegate { _ammo.NewGame(); _monsters.ResetKills(); _lines.ResetUsed(); _powerups.EndAll(); Barrel.ResetMap(); _statsMap = null; _episodeVisited.Clear(); LoadMap(_mapName.Value); })); obj.Buttons.Add(new WristMenuButton("Unload level", (ButtonClickEvent)delegate { Unload(); })); WristMenuSectionProxy obj2 = WristMenuAPI.CreateSection("DOOM Options"); _skillButton = new WristMenuButton(SkillLabel(), (ButtonClickEvent)delegate { CycleSkill(); }); obj2.Buttons.Add(_skillButton); _scaleButton = new WristMenuButton(ScaleLabel(), (ButtonClickEvent)delegate { CycleScale(); }); obj2.Buttons.Add(_scaleButton); _randomButton = new WristMenuButton(RandomLabel(), (ButtonClickEvent)delegate { CycleRandom(); }); obj2.Buttons.Add(_randomButton); _posedButton = new WristMenuButton(PosedLabel(), (ButtonClickEvent)delegate { TogglePosed(); }); obj2.Buttons.Add(_posedButton); _musicButton = new WristMenuButton(MusicLabel(), (ButtonClickEvent)delegate { ToggleMusic(); }); obj2.Buttons.Add(_musicButton); _styleButton = new WristMenuButton(StyleLabel(), (ButtonClickEvent)delegate { CycleStyle(); }); obj2.Buttons.Add(_styleButton); WristMenuSectionProxy obj3 = WristMenuAPI.CreateSection("DOOM Warp"); _warpTarget = _mapName.Value.ToUpperInvariant(); _warpButton = new WristMenuButton(WarpLabel(), (ButtonClickEvent)delegate { _warpTarget = StepMap(_warpTarget, 1); _warpButton.Text = WarpLabel(); }); obj3.Buttons.Add(_warpButton); obj3.Buttons.Add(new WristMenuButton("Next episode", (ButtonClickEvent)delegate { _warpTarget = NextEpisode(_warpTarget); _warpButton.Text = WarpLabel(); })); obj3.Buttons.Add(new WristMenuButton("Warp!", (ButtonClickEvent)delegate { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Warping to " + _warpTarget)); LoadMap(_warpTarget); })); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wrist menu: added sections DOOM Levels (7 buttons), DOOM Options (6 buttons) and DOOM Warp (3 buttons)."); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = _loadKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { LoadMap(_mapName.Value); } _postFx.Tick((Object)(object)_level != (Object)null && _noPostFx.Value); CheckBossExit(); CheckDeath(); TrackSecrets(); if ((Object)(object)_level == (Object)null && (Object)(object)_intermission != (Object)null && _intermission.Showing) { _intermission.Close(done: false); ArmorPatch.Paused = false; _exiting = false; } if ((Object)(object)_music != (Object)null) { _music.Volume = _musicVolume.Value; if ((Object)(object)_level == (Object)null && _music.Playing != null) { _music.Stop(); } } if ((Object)(object)_level != (Object)null && _geo != null && (Object)(object)GM.CurrentPlayerBody != (Object)null && GM.CurrentPlayerBody.Head.position.y - _level.transform.position.y < _geo.MinY - 20f) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Player fell out of the map; returning to start."); TeleportToStart(); } } private void EnsureDataFolder() { try { Directory.CreateDirectory(DataFolder); string path = Path.Combine(DataFolder, "PUT YOUR WADS HERE.txt"); if (!File.Exists(path)) { File.WriteAllText(path, "DLH3VR looks in this folder for:\r\n\r\n * Your Doom IWAD: DOOM2.WAD, DOOM.WAD (from your copy of Doom / Doom II), or Freedoom's\r\n freedoom1.wad / freedoom2.wad (free: https://freedoom.github.io). Not included with the mod.\r\n * Custom map WADs (PWADs) to pick with the wrist menu's WAD button (subfolders work too).\r\n * A General MIDI SoundFont (.sf2) for the music. Without one there's no music.\r\n\r\nOr point WadPath / SoundFont in BepInEx/config/local.doomloader.cfg somewhere else.\r\n\r\nIf you own The Ultimate Doom, DOOM II or Final Doom on Steam and there's no IWAD here, their WADs are\r\nfound by themselves (and show up in the wrist menu's WAD button).\r\n"); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Couldn't create " + DataFolder + ": " + ex.Message)); } } private string FindWad() { string[] iwadOrder; if (Directory.Exists(DataFolder)) { iwadOrder = IwadOrder; foreach (string path in iwadOrder) { string text = Path.Combine(DataFolder, path); if (File.Exists(text)) { return text; } } iwadOrder = Directory.GetFiles(DataFolder, "*.wad"); foreach (string text2 in iwadOrder) { if (WadFile.Kind(text2) == "IWAD") { return text2; } } } List<string> steamWads = SteamWads; iwadOrder = IwadOrder; foreach (string b in iwadOrder) { foreach (string item in steamWads) { if (string.Equals(Path.GetFileName(item), b, StringComparison.OrdinalIgnoreCase) && WadFile.Kind(item) == "IWAD") { ((BaseUnityPlugin)this).Logger.LogInfo((object)("No IWAD in " + DataFolder + "; using your Steam copy: " + item)); return item; } } } foreach (string item2 in steamWads) { if (WadFile.Kind(item2) == "IWAD") { return item2; } } return null; } private string WadKey() { string text = _pwadPath.Value.Trim(); return WadPath + ((text.Length > 0) ? ("|" + text) : ""); } private bool EnsureWad() { if (_wad != null && _wad.Key == WadKey()) { return true; } if (!File.Exists(WadPath)) { ((BaseUnityPlugin)this).Logger.LogError((object)("No WAD found: put DOOM2.WAD, DOOM.WAD or a Freedoom WAD in " + DataFolder + " , set WadPath, or install Doom / DOOM II on Steam. Looked for: " + WadPath)); return false; } try { WadFile wadFile = new WadFile(WadPath); string text = _pwadPath.Value.Trim(); if (text.Length > 0) { if (File.Exists(text)) { wadFile.AddPwad(text); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("PWAD not found, playing the base WAD alone: " + text)); } } _wad = wadFile; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't read " + WadKey() + ": " + ex.Message)); return false; } _palette = new DoomPalette(_wad); _textures = new DoomTextures(_wad); DoomSfx.Load(_wad); _sprites = new SpriteIndex(_wad); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Sprite index: " + _sprites.Count + " frames.")); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded " + string.Join(" + ", _wad.Files.ConvertAll((string f) => Path.GetFileName(f)).ToArray()) + ": " + _wad.Lumps.Count + " lumps, maps: " + string.Join(" ", _wad.MapNames().ToArray()))); return true; } private List<WadChoice> ScanWads() { List<WadChoice> list = new List<WadChoice>(); string text = _wadFolder.Value.Trim(); if (text.Length == 0) { text = Path.GetDirectoryName(WadPath); } if (!Directory.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("WAD folder not found: " + text)); return list; } List<string> list2 = new List<string>(); string[] files = Directory.GetFiles(text); foreach (string text2 in files) { if (text2.EndsWith(".wad", StringComparison.OrdinalIgnoreCase)) { list2.Add(text2); } } files = Directory.GetDirectories(text); for (int i = 0; i < files.Length; i++) { string[] files2 = Directory.GetFiles(files[i]); foreach (string text3 in files2) { if (text3.EndsWith(".wad", StringComparison.OrdinalIgnoreCase)) { list2.Add(text3); } } } list2.Sort(StringComparer.OrdinalIgnoreCase); if (_wadFolder.Value.Trim().Length == 0) { foreach (string steamWad in SteamWads) { bool flag = false; foreach (string item in list2) { if (string.Equals(Path.GetFileName(item), Path.GetFileName(steamWad), StringComparison.OrdinalIgnoreCase)) { flag = true; break; } } if (!flag) { list2.Add(steamWad); } } } List<KeyValuePair<string, List<string>>> list3 = new List<KeyValuePair<string, List<string>>>(); List<KeyValuePair<string, List<string>>> list4 = new List<KeyValuePair<string, List<string>>>(); foreach (string item2 in list2) { string text4 = WadFile.Kind(item2); if (text4 != null) { List<string> list5 = WadFile.ListMaps(item2); if (text4 == "IWAD") { list3.Add(new KeyValuePair<string, List<string>>(item2, list5)); } else if (list5.Count > 0) { list4.Add(new KeyValuePair<string, List<string>>(item2, list5)); } } } foreach (KeyValuePair<string, List<string>> item3 in list3) { if (item3.Value.Count > 0) { list.Add(new WadChoice { Iwad = item3.Key, Pwad = "", Label = Path.GetFileName(item3.Key), Maps = item3.Value }); } } foreach (KeyValuePair<string, List<string>> item4 in list4) { bool flag2 = item4.Value[0].StartsWith("MAP"); string text5 = null; int num = -1; foreach (KeyValuePair<string, List<string>> item5 in list3) { if ((item5.Value.Count > 0 && item5.Value[0].StartsWith("MAP")) == flag2) { string text6 = Path.GetFileName(item5.Key).ToUpperInvariant(); int num2 = ((text6 == "DOOM2.WAD" || text6 == "DOOM.WAD") ? 3 : ((!text6.StartsWith("DOOM")) ? 1 : 2)); if (num2 > num) { text5 = item5.Key; num = num2; } } } if (text5 == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("No " + (flag2 ? "DOOM II" : "DOOM") + "-style IWAD for " + Path.GetFileName(item4.Key) + "; skipped.")); } else { list.Add(new WadChoice { Iwad = text5, Pwad = item4.Key, Label = Path.GetFileNameWithoutExtension(item4.Key) + " (" + Path.GetFileNameWithoutExtension(text5) + ")", Maps = item4.Value }); } } return list; } private string WadLabel() { string text = _pwadPath.Value.Trim(); return "WAD: " + ((text.Length > 0) ? Path.GetFileNameWithoutExtension(text) : Path.GetFileName(WadPath)); } private void CycleWad() { List<WadChoice> list = ScanWads(); if (list.Count == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No playable WADs found."); return; } int num = list.FindIndex((WadChoice c) => string.Equals(c.Iwad, WadPath, StringComparison.OrdinalIgnoreCase) && string.Equals(c.Pwad, _pwadPath.Value.Trim(), StringComparison.OrdinalIgnoreCase)); WadChoice wadChoice = list[(num + 1) % list.Count]; _wadPath.Value = wadChoice.Iwad; _pwadPath.Value = wadChoice.Pwad; _mapName.Value = ((wadChoice.Maps.Count > 0) ? wadChoice.Maps[0] : "MAP01"); _warpTarget = _mapName.Value; if (_warpButton != null) { _warpButton.Text = WarpLabel(); } if (_loadButton != null) { _loadButton.Text = "Load " + _mapName.Value; } _wadButton.Text = WadLabel(); _ammo.NewGame(); _monsters.ResetKills(); _lines.ResetUsed(); _powerups.EndAll(); Barrel.ResetMap(); _statsMap = null; _episodeVisited.Clear(); if ((Object)(object)_music != (Object)null) { _music.Stop(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("WAD selected: " + wadChoice.Label + " (" + wadChoice.Maps.Count + " maps, starts at " + _mapName.Value + "). Press Load to play.")); } private string NextMap(int dir) { if (!EnsureWad()) { return _mapName.Value; } List<string> list = _wad.MapNames(); int num = list.IndexOf(_mapName.Value.ToUpperInvariant()); num = (((num >= 0) ? (num + dir) : 0) % list.Count + list.Count) % list.Count; return list[num]; } private void LoadMap(string mapName) { LoadMap(mapName, keepPosition: false); } private void LoadMap(string mapName, bool keepPosition) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_0cf2: Unknown result type (might be due to invalid IL or missing references) //IL_0cf7: Unknown result type (might be due to invalid IL or missing references) //IL_0cfc: Unknown result type (might be due to invalid IL or missing references) //IL_0d03: Unknown result type (might be due to invalid IL or missing references) //IL_0d1d: Unknown result type (might be due to invalid IL or missing references) //IL_0d14: Unknown result type (might be due to invalid IL or missing references) if (_pendingMap != null || SteamVR_LoadLevel.loading) { _pendingMap = mapName; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene still loading; " + mapName + " will be built when it's ready.")); return; } if ((Object)(object)_intermission != (Object)null && _intermission.Showing) { _intermission.Close(done: false); ArmorPatch.Paused = false; _exiting = false; } if (!_firstLoadHandled && !keepPosition) { _firstLoadHandled = true; string text = _firstScene.Value.Trim(); if (text.Length > 0) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != text) { if (SteamVR_LoadLevel.loading) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"A scene is already loading; try again in a moment."); _firstLoadHandled = false; return; } _pendingMap = mapName; ((BaseUnityPlugin)this).Logger.LogInfo((object)("First load: switching to scene " + text + ", then building " + mapName + ".")); SteamVR_LoadLevel.Begin(text, false, 0.5f, 0f, 0f, 0f, 1f); return; } } } try { if (!EnsureWad()) { return; } Stopwatch stopwatch = Stopwatch.StartNew(); bool flag = false; double num = 0.0; double num2 = 0.0; Vector3 val = Vector3.forward; if (keepPosition && (Object)(object)_level != (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null) { Transform head = GM.CurrentPlayerBody.Head; Vector3 val2 = _level.transform.InverseTransformPoint(head.position); float num3 = ((_geo != null && _geo.MetersPerUnit > 0f) ? _geo.MetersPerUnit : _scale.Value); num = val2.x / num3; num2 = val2.z / num3; val = Vector3.ProjectOnPlane(head.forward, Vector3.up); flag = true; } _monsters.Clear(); if ((Object)(object)_level != (Object)null) { Object.Destroy((Object)(object)_level); } DoomMap doomMap = DoomMap.Load(_wad, mapName); float value = _scale.Value; LevelGeometryBuilder levelGeometryBuilder = new LevelGeometryBuilder(doomMap, _textures, value); _geo = levelGeometryBuilder.Build(); _map = doomMap; _builder = levelGeometryBuilder; long elapsedMilliseconds = stopwatch.ElapsedMilliseconds; LevelBuilder.PickBlockLayer(((BaseUnityPlugin)this).Logger); LevelBuilder levelBuilder = new LevelBuilder(((BaseUnityPlugin)this).Logger, _textures, _palette, _brightness.Value); _level = levelBuilder.Build(_geo, doomMap.Name, new Vector3(_originSide.Value, _originHeight.Value, _originSide.Value), value); if (levelBuilder.AnimatedCount > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Animated textures: " + levelBuilder.AnimatedCount + " materials (" + _textures.Animations.All.Count + " sequences from the " + _textures.Animations.Source + ").")); } Dictionary<int, DoorController> dictionary = new Dictionary<int, DoorController>(); foreach (DoorInfo door in _geo.Doors) { Transform val3 = _level.transform.Find("Sector_" + door.Sector); if (!((Object)(object)val3 == (Object)null)) { DoorController doorController = ((Component)val3).gameObject.AddComponent<DoorController>(); doorController.Door = door; doorController.MetersPerUnit = value; doorController.RequireKeys = _requireKeys.Value; doorController.Log = ((BaseUnityPlugin)this).Logger; doorController.Init(doomMap, _level.transform); dictionary[door.Sector] = doorController; } } _doors = dictionary; Dictionary<int, FloorMover> dictionary2 = new Dictionary<int, FloorMover>(); foreach (FloorMoverInfo floorMover2 in _geo.FloorMovers) { Transform val4 = _level.transform.Find("Floor_" + floorMover2.Sector); if (!((Object)(object)val4 == (Object)null)) { FloorMover floorMover = ((Component)val4).gameObject.AddComponent<FloorMover>(); floorMover.Info = floorMover2; floorMover.MetersPerUnit = value; dictionary2[floorMover2.Sector] = floorMover; } } MonsterManager.Movers = dictionary2; _lines.RequireKeys = _requireKeys.Value; _lines.MaterialFor = levelBuilder.WallMaterial; _lines.Init(doomMap, _geo, _level.transform, value, dictionary2, dictionary); _mapName.Value = doomMap.Name; StartLevelStats(doomMap.Name, force: false); _loadButton.Text = "Load " + doomMap.Name; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Built {doomMap.Name} in {stopwatch.ElapsedMilliseconds} ms (geometry {elapsedMilliseconds} ms): {doomMap.Sectors.Count} sectors, {doomMap.Linedefs.Count} lines, {_geo.SubsectorPolys} subsector polys ({_geo.SkippedSubsectors} skipped), {_geo.Doors.Count} doors, layer {levelBuilder.Layer}"); PlayMapMusic(doomMap.Name); _ammo.PistolIds = _pistolIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < _ammo.PistolIds.Length; i++) { _ammo.PistolIds[i] = _ammo.PistolIds[i].Trim(); } _ammo.MagazineOverrides.Clear(); _ammo.ClearMagazineCache(); string[] array = _magOverrides.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array.Length; j++) { string[] array2 = array[j].Split(new char[1] { '=' }); if (array2.Length == 2) { _ammo.MagazineOverrides[array2[0].Trim()] = array2[1].Trim(); } } _ammo.PouchOffset = ParseVec(_pouchOffset, new Vector3(0f, -0.4f, 0.18f)); _ammo.PreferLoaders = _preferLoaders.Value; byte[] array3 = _wad.Read("DSITEMUP"); if (array3 != null) { int sampleRate; float[] array4 = DoomSound.Decode(array3, out sampleRate); if (array4 != null) { AudioClip val5 = AudioClip.Create("DSITEMUP", array4.Length, 1, sampleRate, false); val5.SetData(array4, 0); _ammo.SetPickupSound(val5); } } DoomSfx.MetersPerUnit = value; _ammo.SpawnPickups(doomMap, levelGeometryBuilder, _textures, _palette, _brightness.Value, _level.transform, value, LevelBuilder.CutoutShader); ApplyRandomSettings(); _ammo.WeaponDefs[2001].Ids = _shotgunIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2002].Ids = _chaingunIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2002].MagazineIds = _chaingunMags.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[82].Ids = _superShotgunIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2003].Ids = _rocketIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2005].Ids = _chainsawIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2004].Ids = _plasmaIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); _ammo.WeaponDefs[2006].Ids = _bfgIds.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); byte[] array5 = _wad.Read("DSWPNUP"); if (array5 != null) { int sampleRate2; float[] array6 = DoomSound.Decode(array5, out sampleRate2); if (array6 != null) { AudioClip val6 = AudioClip.Create("DSWPNUP", array6.Length, 1, sampleRate2, false); val6.SetData(array6, 0); _ammo.SetWeaponSound(val6); } } _ammo.SpawnWeapons(doomMap, levelGeometryBuilder, _level.transform, value); _ammo.OnLevelLoaded(_level.transform); Barrel.SpawnAll(doomMap, levelGeometryBuilder, _ammo, _level.transform, value, levelBuilder.Layer, ((BaseUnityPlugin)this).Logger); Decorations.SpawnAll(doomMap, levelGeometryBuilder, _ammo, _sprites, _level.transform, value, levelBuilder.Layer, ((BaseUnityPlugin)this).Logger); _powerups.Ids.Clear(); foreach (KeyValuePair<int, ConfigEntry<string>> powerupId in _powerupIds) { string text2 = powerupId.Value.Value.Trim(); if (text2.Length > 0 && !text2.Equals("auto", StringComparison.OrdinalIgnoreCase)) { _powerups.Ids[powerupId.Key] = text2.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); } } _powerups.RandomMode = _randomWeapons.Value; _powerups.IncludeModded = _randomModded.Value; _powerups.OnLevelLoaded(doomMap, levelGeometryBuilder, levelBuilder, _level.transform, value); _monsters.Replacements.Clear(); if (_monstersOn.Value) { _monsters.MaxSosigs = _maxSosigs.Value; _monsters.WeaponDropChance = _weaponDropChance.Value; _monsters.ClassicStyle = _monsterStyle.Value == MonsterStyle.Classic; _monsters.Sprites = _sprites; ApplyClassicTuning(); foreach (KeyValuePair<int, ConfigEntry<string>> monsterSosig in _monsterSosigs) { string[] array7 = monsterSosig.Value.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (array7.Length != 0) { _monsters.Replacements[monsterSosig.Key] = array7; } } _monsters.Begin(doomMap, levelGeometryBuilder, _level.transform, value); } else { _monsters.Clear(); } if (flag) { int num4 = levelGeometryBuilder.SectorAt(num, num2); float num5 = ((num4 >= 0) ? ((float)doomMap.Sectors[num4].Floor * value) : _geo.PlayerStart.Y); Vector3 val7 = _level.transform.TransformPoint(new Vector3((float)num * value, num5 + 0.05f, (float)num2 * value)); GM.CurrentMovementManager.TeleportToPoint(val7, true, (((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward); } else { TeleportToStart(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load " + mapName + ": " + ex)); } } private string ScaleLabel() { return "Scale 1/" + Mathf.RoundToInt(1f / _scale.Value); } private void CycleScale() { int value = Mathf.RoundToInt(1f / _scale.Value); int num = Array.IndexOf(ScalePresets, value); int num2 = ScalePresets[(num + 1) % ScalePresets.Length]; _scale.Value = 1f / (float)num2; _scaleButton.Text = ScaleLabel(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Scale set to 1/" + num2 + " m per Doom unit (Doom player = " + (56f / (float)num2).ToString("0.00") + " m tall).")); if ((Object)(object)_level != (Object)null) { LoadMap(_mapName.Value, keepPosition: true); } } private void Unload() { if ((Object)(object)_intermission != (Object)null && _intermission.Showing) { _intermission.Close(done: false); ArmorPatch.Paused = false; _exiting = false; } if ((Object)(object)_level != (Object)null) { Object.Destroy((Object)(object)_level); } _level = null; _geo = null; _map = null; _builder = null; _postFx.Restore(); if ((Object)(object)_music != (Object)null) { _music.Stop(); } _ammo.OnLevelUnloaded(); _powerups.OnLevelUnloaded(); _monsters.Clear(); _lines.Clear(); } private void CheckDeath() { bool flag = GM.IsDead(); if (flag && !_wasDead && (Object)(object)_level != (Object)null && _deathRestart.Value && _deathMap == null) { _deathMap = _mapName.Value; _deadSince = Time.time; _broughtBack = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)("You died on " + _deathMap + ". The level restarts when you respawn.")); } _wasDead = flag; if (_deathMap == null) { return; } if (flag) { FVRSceneSettings currentSceneSettings = GM.CurrentSceneSettings; float num = 4f + (((Object)(object)currentSceneSettings != (Object)null) ? (currentSceneSettings.PlayerDeathFade + currentSceneSettings.PlayerRespawnLoadDelay) : 0f); if (!_broughtBack && Time.time - _deadSince > num + 6f) { _broughtBack = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Still dead after " + (Time.time - _deadSince).ToString("0") + " s; bringing the player back.")); try { ManagerSingleton<GM>.Instance.BringBackPlayer(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("BringBackPlayer failed: " + ex.Message)); } } } else if (!SteamVR_LoadLevel.loading) { string deathMap = _deathMap; _deathMap = null; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Respawned: restarting " + deathMap + " from a pistol start.")); _ammo.LoseEverything(); _statsMap = null; _monsters.ResetKills(); _lines.ResetUsed(); _powerups.EndAll(); Barrel.ResetMap(); if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.ResetHealth(); } if ((Object)(object)_level != (Object)null) { LoadMap(deathMap); return; } _pendingMap = deathMap; ((MonoBehaviour)this).StartCoroutine(LoadWhenPlayerReady()); } } private string WarpLabel() { return "Warp to: " + _warpTarget; } private string StepMap(string from, int dir) { if (!EnsureWad()) { return from; } List<string> list = _wad.MapNames(); if (list.Count == 0) { return from; } int num = list.IndexOf(from); num = (((num >= 0) ? (num + dir) : 0) % list.Count + list.Count) % list.Count; return list[num]; } private string NextEpisode(string from) { if (!EnsureWad()) { return from; } List<string> list = _wad.MapNames(); if (list.Count == 0) { return from; } int num = Math.Max(0, list.IndexOf(from)); for (int i = 1; i < list.Count; i++) { string text = list[(num + i) % list.Count]; if ((text.Length == 4 && text[0] == 'E' && text[2] == 'M' && text[3] == '1') || (text.StartsWith("MAP") && (text.EndsWith("01") || text.EndsWith("11") || text.EndsWith("21") || text.EndsWith("31")))) { return text; } } return from; } private string RandomLabel() { return "Random guns " + _randomWeapons.Value; } private void CycleRandom() { _randomWeapons.Value = (RandomWeapons)((int)(_randomWeapons.Value + 1) % 3); _randomButton.Text = RandomLabel(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Random weapons: " + _randomWeapons.Value.ToString() + " (applies from the next New game / map load).")); } private string PosedLabel() { return "Posed guns only: " + (_posedOnly.Value ? "ON" : "OFF"); } private void TogglePosed() { _posedOnly.Value = !_posedOnly.Value; _posedButton.Text = PosedLabel(); ApplyRandomSettings(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Posed weapons only: " + (_posedOnly.Value ? "on" : "off") + " (from the next weapon spawned / map load).")); } private void ApplyRandomSettings() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) WeaponCatalog catalog = _ammo.Catalog; _ammo.RandomMode = _randomWeapons.Value; if (_appliedSets != _randomSets.Value || _appliedModded != _randomModded.Value) { _appliedSets = _randomSets.Value; _appliedModded = _randomModded.Value; catalog.IncludeModded = _randomModded.Value; catalog.AllowedSets.Clear(); string[] array = _randomSets.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { try { catalog.AllowedSets.Add((OTagSet)Enum.Parse(typeof(OTagSet), text.Trim(), ignoreCase: true)); } catch (Exception) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Unknown item set '" + text.Trim() + "' in [Weapons] Sets.")); } } catalog.Reset(); } if (_posedOnly.Value) { PoseKitPoses.Refresh(((BaseUnityPlugin)this).Logger); } if (_appliedPosed != _posedOnly.Value || (_posedOnly.Value && _appliedPoseVersion != PoseKitPoses.Version)) { _appliedPosed = _posedOnly.Value; _appliedPoseVersion = PoseKitPoses.Version; catalog.PosedOnly = _posedOnly.Value; catalog.Reset(); } } private string SkillLabel() { return "Skill: " + ThingFlags.SkillName; } private void CycleSkill() { _skill.Value = _skill.Value % 5 + 1; ThingFlags.Skill = _skill.Value; _skillButton.Text = SkillLabel(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Skill set to " + ThingFlags.SkillName + " (takes effect on the next New game / map load).")); } private string MusicLabel() { return "Music " + (_musicOn.Value ? "ON" : "OFF"); } private string StyleLabel() { return "Monsters: " + _monsterStyle.Value; } private void ApplyClassicTuning() { ClassicRules.DamageTuning tuning = ClassicMonster.Tuning; tuning.NineMil = Mathf.Max(0.1f, _classicDamage.Value); tuning.Curve = _classicCurve.Value; tuning.Explosive = _classicExplosive.Value; tuning.Melee = _classicMelee.Value; ClassicMonster.HitsToLog = 20; } private void CycleStyle() { _monsterStyle.Value = ((_monsterStyle.Value == MonsterStyle.Sosigs) ? MonsterStyle.Classic : MonsterStyle.Sosigs); _styleButton.Text = StyleLabel(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Monster style: " + _monsterStyle.Value)); if ((Object)(object)_level != (Object)null && _map != null && _builder != null && _monstersOn.Value) { _monsters.ClassicStyle = _monsterStyle.Value == MonsterStyle.Classic; _monsters.Sprites = _sprites; ApplyClassicTuning(); _monsters.Begin(_map, _builder, _level.transform, _geo.MetersPerUnit); } } private void ToggleMusic() { _musicOn.Value = !_musicOn.Value; _musicButton.Text = MusicLabel(); if (!_musicOn.Value) { if ((Object)(object)_music != (Object)null) { _music.Stop(); } } else if ((Object)(object)_level != (Object)null) { PlayMapMusic(_mapName.Value); } } private void PlayMapMusic(string mapName) { if (!_musicOn.Value || _wad == null) { return; } string text = Song.LumpForMap(_wad, mapName); if (text == null || _wad.Find(text) == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("No music lump for " + mapName)); if ((Object)(object)_music != (Object)null) { _music.Stop(); } } else { PlayMusicLump(text); } } private void PlayMusicLump(string lump) { if (!_musicOn.Value || _wad == null) { return; } try { if (_wad.Find(lump) == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("No music lump " + lump)); } else { if ((Object)(object)_music != (Object)null && _music.Playing == lump) { return; } if ((Object)(object)_music == (Object)null) { if (_soundFontFailed) { return; } if (!File.Exists(SoundFontPath)) { _soundFontFailed = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("SoundFont not found, music disabled: " + SoundFontPath)); return; } Stopwatch stopwatch = Stopwatch.StartNew(); SoundFont soundFont = new SoundFont(SoundFontPath); _music = MusicPlayer.Create(soundFont); _music.Volume = _musicVolume.Value; ((BaseUnityPlugin)this).Logger.LogInfo((object)("SoundFont " + Path.GetFileName(SoundFontPath) + " loaded in " + stopwatch.ElapsedMilliseconds + " ms (" + soundFont.Presets.Count + " presets), output " + AudioSettings.outputSampleRate + " Hz")); } Song song = Song.Load(_wad.Read(lump), lump); if (song == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)(lump + " is not MUS or MIDI; skipping music.")); return; } _music.Play(song); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Music: " + lump + " (" + song.Length.ToString("0") + " s loop)")); } } catch (Exception ex) { _soundFontFailed = (Object)(object)_music == (Object)null; ((BaseUnityPlugin)this).Logger.LogError((object)("Music failed: " + ex)); } } private Vector3 ParseVec(ConfigEntry<string> e, Vector3 fallback) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) string[] array = e.Value.Split(new char[1] { ',' }); if (array.Length == 3 && float.TryParse(array[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { return new Vector3(result, result2, result3); } ((BaseUnityPlugin)this).Logger.LogWarning((object)("Bad " + ((ConfigEntryBase)e).Definition.Key + " value '" + e.Value + "', using default.")); return fallback; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (_pendingMap != null) { if (((Scene)(ref scene)).name != _firstScene.Value.Trim()) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Expected scene " + _firstScene.Value + " but " + ((Scene)(ref scene)).name + " loaded; building " + _pendingMap + " here.")); } ((MonoBehaviour)this).StartCoroutine(LoadWhenPlayerReady()); } } private IEnumerator LoadWhenPlayerReady() { float giveUp = Time.realtimeSinceStartup + 20f; while (((Object)(object)GM.CurrentPlayerBody == (Object)null || (Object)(object)GM.CurrentMovementManager == (Object)null || SteamVR_LoadLevel.loading) && Time.realtimeSinceStartup < giveUp) { yield return null; } yield return (object)new WaitForSeconds(1f); while (SteamVR_LoadLevel.loading && Time.realtimeSinceStartup < giveUp + 20f) { yield return null; } string pendingMap = _pendingMap; _pendingMap = null; if (pendingMap != null) { LoadMap(pendingMap, keepPosition: false); } } private void CheckBossExit() { if (!((Object)(object)_level == (Object)null) && !_exiting && !(Time.time < _nextBossCheck)) { _nextBossCheck = Time.time + 1f; int doomType; switch (_mapName.Value.ToUpperInvariant()) { default: return; case "E1M8": doomType = 3003; break; case "E2M8": doomType = 16; break; case "E3M8": doomType = 7; break; case "E4M8": doomType = 7; break; } _monsters.Count(doomType, out var spawned, out var alive); if (spawned > 0 && alive == 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Boss defeated on " + _mapName.Value + ".")); ((MonoBehaviour)this).StartCoroutine(ExitLevel(secret: false)); } } } private IEnumerator ExitLevel(bool secret) { if (_exiting || _wad == null) { yield break; } _exiting = true; string from = _mapName.Value; string next = Specials.NextMap(from, secret, _wad.MapNames()); ((BaseUnityPlugin)this).Logger.LogInfo((object)((secret ? "Secret exit" : "Exit") + " from " + from + ((next != null) ? (" -> " + next) : ": that was the last map in this WAD."))); LevelStats levelStats = CurrentStats(next, secret); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Level stats: kills {0}/{1} ({2}%), items {3}/{4} ({5}%), secrets {6}/{7} ({8}%), time {9}, par {10}.", levelStats.Kills, levelStats.TotalKills, levelStats.KillPct, levelStats.Items, levelStats.TotalItems, levelStats.ItemPct, levelStats.Secrets, levelStats.TotalSecrets, levelStats.SecretPct, Intermission.TimeText(levelStats.Seconds), (levelStats.ParSeconds >= 0) ? Intermission.TimeText(levelStats.ParSeconds) : "none")); if (!_intermissionOn.Value || (Object)(object)_level == (Object)null) { yield return (object)new WaitForSeconds(1.2f); _exiting = false; if (next != null) { LoadMap(next); } yield break; } _monsters.Clear(); ArmorPatch.Paused = true; PlayMusicLump((Intermission.ParseMapNumber(from, out var _) || _wad.Find("D_INTER") == null) ? "D_DM2INT" : "D_INTER"); _intermission.Show(new IntermissionView(_textures, _palette, levelStats), _level.transform, delegate { ArmorPatch.Paused = false; _exiting = false; if (next != null) { LoadMap(next); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"That was the last level; back to it."); PlayMapMusic(from); _monsters.Begin(_map, _builder, _level.transform, _geo.MetersPerUnit); } }); } private void StartLevelStats(string map, bool force) { if (force || !(_statsMap == map)) { _statsMap = map; _levelStart = Time.time; _secretsFound.Clear(); } } private void TrackSecrets() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_level == (Object)null) && _map != null && _builder != null && !_exiting && !((Object)(object)GM.CurrentPlayerBody == (Object)null)) { Vector3 val = _level.transform.InverseTransformPoint(GM.CurrentPlayerBody.Head.position) / _geo.MetersPerUnit; int num = _builder.SectorAt(val.x, val.z); if (num >= 0 && _map.Sectors[num].Special == 9 && _secretsFound.Add(num)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Secret found (sector " + num + "): " + _secretsFound.Count + " on " + _map.Name + ".")); } } } private LevelStats CurrentStats(string next, bool secret) { LevelStats levelStats = new LevelStats { Map = _mapName.Value.ToUpperInvariant(), NextMap = next, Secret = secret, Seconds = Mathf.Max(0, (int)(Time.time - _levelStart)) }; levelStats.ParSeconds = (_wad.PwadMaps.Contains(levelStats.Map) ? (-1) : Intermission.Par(levelStats.Map)); if (_map != null) { for (int i = 0; i < _map.Things.Count; i++) { Thing thing = _map.Things[i]; if (!ThingFlags.Present(thing.Flags)) { continue; } if (Intermission.CountKill(thing.Type)) { levelStats.TotalKills++; } if (Intermission.CountItems.Contains(thing.Type)) { levelStats.TotalItems++; if (_ammo.IsTaken(i)) { levelStats.Items++; } } } foreach (Sector sector in _map.Sectors) { if (sector.Special == 9) { levelStats.TotalSecrets++; } } } levelStats.Kills = Mathf.Min(_monsters.KilledCount, levelStats.TotalKills); levelStats.Secrets = _secretsFound.Count; if (Intermission.ParseEpisode(levelStats.Map, out var e, out var _)) { if (_episodeVisited.Count > 0 && Intermission.ParseEpisode(_episodeVisited[0], out var e2, out var _) && e2 != e) { _episodeVisited.Clear(); } if (!_episodeVisited.Contains(levelStats.Map)) { _episodeVisited.Add(levelStats.Map); } levelStats.Visited.AddRange(_episodeVisited); } return levelStats; } private void TeleportTo(LineTrigger t) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_level == (Object)null) && _geo != null && !((Object)(object)GM.CurrentMovementManager == (Object)null)) { float metersPerUnit = _geo.MetersPerUnit; Vector3 val = _level.transform.TransformPoint(new Vector3((float)t.DestX * metersPerUnit, (float)t.DestFloor * metersPerUnit + 0.05f, (float)t.DestY * metersPerUnit)); float num = (float)t.DestAngle * ((float)Math.PI / 180f); Vector3 worldFloor = (((Object)(object)GM.CurrentPlayerBody != (Object)null) ? (GM.CurrentPlayerBody.Head.position - Vector3.up * 1.6f) : val); GM.CurrentMovementManager.TeleportToPoint(val, true, new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num))); _lines.ResetPath(); DoomSfx.Play("DSTELEPT", val); TeleportFog.Spawn(worldFloor); TeleportFog.Spawn(val + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 0.6f); } } private void TeleportToStart() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_level == (Object)null) && _geo != null && !((Object)(object)GM.CurrentMovementManager == (Object)null)) { V3 playerStart = _geo.PlayerStart; Vector3 val = _level.transform.TransformPoint(new Vector3(playerStart.X, playerStart.Y + 0.05f, playerStart.Z)); float num = _geo.PlayerStartAngleDeg * ((float)Math.PI / 180f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); GM.CurrentMovementManager.TeleportToPoint(val, true, val2); if ((Object)(object)_lines != (Object)null) { _lines.ResetPath(); } } } } } namespace DoomLoader.Unity { public sealed class AmmoSystem : MonoBehaviour { private sealed class Pickup { public GameObject Go; public AmmoPickupDef Def; public ItemPickupDef Item; public KeyDef Key; public float FloorY; public int ThingIndex; } public sealed class WeaponDef { public int DoomType; public string Name; public string[] Ids; public string SearchName; public WeaponCategory Category; public OTagFirearmAction PreferAction; public DoomAmmo Ammo; public int Amount; public string[] MagazineIds = new string[0]; public int PreferredCapacity; public int AmmoPerRound = 1; } private sealed class WeaponPickup { public FVRPhysicalObject Gun; public int ThingIndex; public DoomAmmo Ammo; public int Amount; public string Name; public int DoomType; public Vector3 Hover; public Quaternion Lie; public Vector3 LocalCenter; public float Phase; public Rigidbody Body; public bool WasKinematic; public bool HadGravity; } public ManualLogSource Log; public readonly AmmoPool Pool = new AmmoPool(); public string[] PistolIds = new string[3] { "M9A1", "M9A3", "Beretta92FS" }; public Vector3 PouchOffset = new Vector3(0f, -0.4f, 0.18f); public float PouchRadius = 0.14f; public float PickupRadius = 0.8f; private float _flashUntil; private FVRFireArm _pistol; private FVRFireArm _lastFirearm; private readonly FVRInteractiveObject[] _prevHeld = (FVRInteractiveObject[])(object)new FVRInteractiveObject[2]; private readonly List<Pickup> _pickups = new List<Pickup>(); private AudioClip _pickupSound; private bool _levelActive; private Transform _levelRoot; private string _pickupMap; private readonly HashSet<int> _taken = new HashSet<int>(); public WeaponCatalog Catalog; public RandomWeapons RandomMode; private readonly List<FVRPhysicalObject> _owned = new List<FVRPhysicalObject>(); private GameObject _pouch; private MeshRenderer _pouchRenderer; private Material _plainBox; private Material[] _skin; private Material[] _skinFlash; private BitmapFontData _wadFont; private bool _boxFlashShown = true; private TextMesh _pouchText; private BitmapText _pouchBitmap; public BitmapFontData TextFont; private static readonly Color CounterRed = new Color(0.95f, 0.15f, 0.1f); private HudIcons _hudIcons; private DoomTextures _hudIconsFor; private Mesh _faceMesh; private MeshRenderer _faceRenderer; private Transform _faceT; private string _faceShown; private float _ouchUntil; private float _grinUntil; private float _nextLook; private float _faceHp = 100f; private int _lookDir; private readonly Random _faceRng = new Random(); private const float FaceHeight = 0.05f; private string _powerupIcons; private const float PouchWidth = 0.3f; private const float PouchDepth = 0.13f; private const float BarWidth = 0.29f; private const float BarHeight = 0.0348f; private const float BarCenter = -0.043599997f; private const float BarTextCenter = 0.0194f; private StatusBar _bar; private Texture2D _barTex; private Material _barMat; private GameObject _barGo; private string _barKey; private readonly byte[] _barBuf = new byte[40960]; private readonly StatusBarState _barState = new StatusBarState(); private readonly bool[] _arms = new bool[6]; private string _powerupLine; public bool PreferLoaders = true; private readonly Dictionary<string, FVRObject> _loaderByGun = new Dictionary<string, FVRObject>(); public readonly Dictionary<string, string> MagazineOverrides = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, FVRObject> _magByGun = new Dictionary<string, FVRObject>(); private readonly HashSet<string> _loggedPrefabs = new HashSet<string>(); private readonly Dictionary<string, string[]> _preferredMags = new Dictionary<string, string[]>(); private readonly Dictionary<string, int> _preferredCap = new Dictionary<string, int>(); public static readonly Dictionary<FireArmRoundType, DoomAmmo> SlotAmmo = new Dictionary<FireArmRoundType, DoomAmmo>(); public static readonly Dictionary<FireArmRoundType, int> SlotCost = new Dictionary<FireArmRoundType, int>(); private DoomTextures _ptex; private DoomPalette _ppal; private int _pboost; private Transform _proot; private float _ps; private Shader _pcutout; private readonly Dictionary<string, Material> _pmats = new Dictionary<string, Material>(); private readonly Dictionary<string, Mesh> _pmeshes = new Dictionary<string, Mesh>(); private LevelGeometryBuilder _pbuilder; private DoomMap _pmap; public readonly Dictionary<int, WeaponDef> WeaponDefs = new Dictionary<int, WeaponDef> { { 2001, new WeaponDef { DoomType = 2001, Name = "Shotgun", Ids = new string[1] { "I37Shorty" }, SearchName = "I37Shorty", Category = WeaponCategory.Shotgun, PreferAction = (OTagFirearmAction)4, Ammo = DoomAmmo.Shells, Amount = 8 } }, { 2002, new WeaponDef { DoomType = 2002, Name = "Chaingun", Ids = new string[1] { "SpectreM4" }, SearchName = "Spectre", Category = WeaponCategory.Automatic, PreferAction = (OTagFirearmAction)6, Ammo = DoomAmmo.Bullets, Amount = 20, PreferredCapacity = 50 } }, { 82, new WeaponDef { DoomType = 82, Name = "Super shotgun", Ids = new string[1] { "BreakActionShorty" }, SearchName = "Shorty", Category = WeaponCategory.SuperShotgun, PreferAction = (OTagFirearmAction)1, Ammo = DoomAmmo.Shells, Amount = 8 } }, { 2005, new WeaponDef { DoomType = 2005, Name = "Chainsaw", Ids = new string[1] { "Chainsaw" }, SearchName = "Chainsaw", Category = WeaponCategory.Melee, PreferAction = (OTagFirearmAction)0, Ammo = DoomAmmo.Bullets, Amount = 0 } }, { 2003, new WeaponDef { DoomType = 2003, Name = "Rocket launcher", Ids = new string[1] { "RPG7" }, SearchName = "RPG7", Category = WeaponCategory.Launcher, PreferAction = (OTagFirearmAction)0, Ammo = DoomAmmo.Rockets, Amount = 2 } }, { 2004, new WeaponDef { DoomType = 2004, Name = "Plasma rifle", Ids = new string[1] { "AKM" }, SearchName = "AKM", Category = WeaponCategory.BattleRifle, PreferAction = (OTagFirearmAction)6, Ammo = DoomAmmo.Cells, Amount = 40, MagazineIds = new string[1] { "MagAKM" }, PreferredCapacity = 30 } }, { 2006, new WeaponDef { DoomType = 2006, Name = "BFG 9000", Ids = new string[1] { "HiroEnkiYTRailgun" }, SearchName = "Railgun", Category = WeaponCategory.Heavy, PreferAction = (OTagFirearmAction)0, Ammo = DoomAmmo.Cells, Amount = 40, AmmoPerRound = 40 } } }; private AudioClip _weaponSound; public float HoverHeight = 0.55f; public float SpinDegreesPerSecond = 100f; public float BobMeters = 0.04f; private readonly List<WeaponPickup> _weapons = new List<WeaponPickup>(); private readonly Random _dropRng = new Random(); public readonly DoomPlayerStatus Status = new DoomPlayerStatus(); private int _shownHealth = -1; private string _message; private float _messageUntil; public static AmmoSystem Current; public string PowerupIcons { get { return _powerupIcons; } set { if (!(value == _powerupIcons)) { _powerupIcons = value; UpdateHudText(); } } } public string PowerupLine { get { return _powerupLine; } set { if (!(value == _powerupLine)) { _powerupLine = value; UpdateHudText(); } } } public Transform PouchTransform { get { if (!((Object)(object)_pouch != (Object)null) || !_pouch.activeSelf) { return null; } return _pouch.transform; } } public Transform LevelRoot => _proot; private void Awake() { Pool.ResetToStart(); Pool.Changed += UpdateHudText; Status.Changed += UpdateHudText; ArmorPatch.Status = Status; DoorController.Player = Status; Current = this; } public void OnLevelLoaded(Transform root) { _levelActive = true; _levelRoot = root; ArmorPatch.Active = true; if ((Object)(object)_pistol == (Object)null) { Pool.ResetToStart(); ((MonoBehaviour)this).StartCoroutine(GiveStartingPistol()); } } public void NewGame() { if (Catalog != null) { Catalog.NewGame(); } ResetPlayer(); } public void LoseEverything() { foreach (FVRPhysicalObject item in _owned) { if (!((Object)(object)item == (Object)null)) { if (((FVRInteractiveObject)item).IsHeld && (Object)(object)((FVRInteractiveObject)item).m_hand != (Object)null) { ((FVRInteractiveObject)item).m_hand.EndInteractionIfHeld((FVRInteractiveObject)(object)item); } if ((Object)(object)item.QuickbeltSlot != (Object)null) { item.SetQuickBeltSlot((FVRQuickBeltSlot)null); } FVRFireArm val = (FVRFireArm)(object)((item is FVRFireArm) ? item : null); if ((Object)(object)val != (Object)null && (Object)(object)val.Magazine != (Object)null && !val.Magazine.IsIntegrated) { Object.Destroy((Object)(object)((Component)val.Magazine).gameObject); } Object.Destroy((Object)(object)((Component)item).gameObject); } } _owned.Clear(); ResetPlayer(); Pool.ResetToStart(); } private void ResetPlayer() { Status.Reset(); if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.ResetHealth(); } if ((Object)(object)_pistol != (Object)null) { if (((FVRInteractiveObject)_pistol).IsHeld && (Object)(object)((FVRInteractiveObject)_pistol).m_hand != (Object)null) { ((FVRInteractiveObject)_pistol).m_hand.EndInteractionIfHeld((FVRInteractiveObject)(object)_pistol); } if ((Object)(object)_pistol.Magazine != (Object)null) { Object.Destroy((Object)(object)((Component)_pistol.Magazine).gameObject); } Object.Destroy((Object)(object)((Component)_pistol).gameObject); } _pistol = null; _lastFirearm = null; Array.Clear(_arms, 0, _arms.Length); _taken.Clear(); _pickupMap = null; } public void OnLevelUnloaded() { _levelActive = false; ArmorPatch.Active = false; _pickups.Clear(); if ((Object)(object)_pouch != (Object)null) { _pouch.SetActive(false); } DestroyUnclaimedWeapons(); } public void SetPickupSound(AudioClip clip) { _pickupSound = clip; } private void Update() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) if (!_levelActive) { return; } if ((Object)(object)_levelRoot == (Object)null) { OnLevelUnloaded(); return; } FVRPlayerBody currentPlayerBody = GM.CurrentPlayerBody; FVRMovementManager currentMovementManager = GM.CurrentMovementManager; if (!((Object)(object)currentPlayerBody == (Object)null) && !((Object)(object)currentPlayerBody.Head == (Object)null) && !((Object)(object)currentMovementManager == (Object)null) && currentMovementManager.Hands != null) { EnsurePouch(); PlacePouch(currentPlayerBody.Head); for (int i = 0; i < currentMovementManager.Hands.Length && i < 2; i++) { HandleHand(i, currentMovementManager.Hands[i]); } UpdatePickups(currentPlayerBody.Head); UpdateWeapons(); int num = Mathf.RoundToInt(HealthPercent()); if (num != _shownHealth) { _shownHealth = num; UpdateHudText(); } if (_message != null && Time.time >= _messageUntil) { _message = null; UpdateHudText(); } if ((Object)(object)_barGo != (Object)null && _barGo.activeSelf) { UpdateBar(); } else { UpdateFace(); } bool flag = Time.time < _flashUntil; ApplyBoxSkin(flag); if ((Object)(object)_pouchText != (Object)null) { _pouchText.color = (flag ? Color.white : CounterRed); } if ((Object)(object)_pouchBitmap != (Object)null) { _pouchBitmap.SetColor((Color)((_pouchBitmap.Font != _wadFont || _wadFont == null) ? (flag ? Color.white : CounterRed) : (flag ? new Color(1f, 0.55f, 0.55f) : Color.white))); } } } private void ApplyBoxSkin(bool flash) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pouchRenderer == (Object)null) { return; } if (_skin == null) { if ((Object)(object)_plainBox != (Object)null) { _plainBox.color = (flash ? new Color(0.6f, 0.1f, 0.1f) : new Color(0.12f, 0.12f, 0.11f)); } } else if (flash != _boxFlashShown || ((Renderer)_pouchRenderer).sharedMaterials.Length != 2 || !((Object)(object)((Renderer)_pouchRenderer).sharedMaterials[0] == (Object)(object)(flash ? _skinFlash : _skin)[0])) { _boxFlashShown = flash; ((Renderer)_pouchRenderer).sharedMaterials = (flash ? _skinFlash : _skin); } } private void BuildWadSkin(DoomTextures tex, DoomPalette pal, bool doom2) { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) try { _wadFont = WadFont.Build(tex, pal); } catch (Exception ex) { Log.LogWarning((object)("WAD font unavailable: " + ex.Message)); _wadFont = null; } _skin = (_skinFlash = null); string text = null; string[] array = ((!doom2) ? new string[2] { "FLOOR7_2", "GRNROCK" } : new string[2] { "GRNROCK", "FLOOR7_2" }); foreach (string text2 in array) { if (tex.GetFlat(text2) != null) { text = text2; break; } } IndexedImage indexedImage = ((text != null) ? tex.GetFlat(text) : null); Shader val = Shader.Find("Unlit/Texture"); if (indexedImage != null && (Object)(object)val != (Object)null) { _skin = (Material[])(object)new Material[2] { FlatMaterial(indexedImage, pal, 14, flash: false, val), FlatMaterial(indexedImage, pal, 4, flash: false, val) }; _skinFlash = (Material[])(object)new Material[2] { FlatMaterial(indexedImage, pal, 14, flash: true, val), FlatMaterial(indexedImage, pal, 4, flash: true, val) }; } Log.LogInfo((object)("Pouch skin from the WAD: " + ((_wadFont != null) ? ("HUD font (STCFN, " + _wadFont.Glyphs.Count + " glyphs)") : "no HUD font, keeping the TTF") + ", box " + (text ?? "plain (no border flat)") + ".")); if ((Object)(object)_pouchBitmap != (Object)null) { _pouchBitmap.Font = _wadFont ?? TextFont; _pouchBitmap.Color = ((_wadFont != null) ? Color.white : CounterRed); } _boxFlashShown = true; ApplyBoxSkin(flash: false); } private static Material FlatMaterial(IndexedImage flat, DoomPalette pal, int colormap, bool flash, Shader sh) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown byte[] array = flat.ToRgbaBottomUp(pal, colormap); if (flash) { for (int i = 0; i < array.Length; i += 4) { array[i] = (byte)Mathf.Min(255f, (float)(int)array[i] * 0.6f + 110f); array[i + 1] = (byte)((float)(int)array[i + 1] * 0.35f); array[i + 2] = (byte)((float)(int)array[i + 2] * 0.35f); } } Texture2D val = new Texture2D(flat.Width, flat.Height, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; val.LoadRawTextureData(array); val.Apply(false, true); return new Material(sh) { mainTexture = (Texture)(object)val }; } private static Mesh BoxMesh(Vector3 size, float uvPerMeter) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_00a2: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); List<int> list4 = new List<int>(); Vector3 val = size * 0.5f; Vector3[] array = (Vector3[])(object)new Vector3[6] { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back }; foreach (Vector3 val2 in array) { Vector3 val3 = ((Mathf.Abs(val2.y) > 0.5f) ? Vector3.forward : Vector3.up); Vector3 val4 = Vector3.Cross(val2, val3); float num = Mathf.Abs(Vector3.Dot(val4, size)); float num2 = Mathf.Abs(Vector3.Dot(val3, size)); Vector3 val5 = Vector3.Scale(val2, val); int count = list.Count; Vector2[] array2 = (Vector2[])(object)new Vector2[4] { new Vector2(-1f, -1f), new Vector2(-1f, 1f), new Vector2(1f, 1f), new Vector2(1f, -1f) }; foreach (Vector2 val6 in array2) { list.Add(val5 + val4 * (val6.x * num * 0.5f) + val3 * (val6.y * num2 * 0.5f)); list2.Add(new Vector2((val6.x + 1f) * 0.5f * num, (val6.y + 1f) * 0.5f * num2) * uvPerMeter); } List<int> obj = ((val2 == Vector3.up) ? list3 : list4); obj.Add(count); obj.Add(count + 1); obj.Add(count + 2); obj.Add(count); obj.Add(count + 2); obj.Add(count + 3); } Mesh val7 = new Mesh { name = "DoomPouch" }; val7.SetVertices(list); val7.SetUVs(0, list2); val7.subMeshCount = 2; val7.SetTriangles(list3, 0); val7.SetTriangles(list4, 1); val7.RecalculateNormals(); val7.RecalculateBounds(); return val7; } private void EnsurePouch() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_038a: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pouch != (Object)null) { if (!_pouch.activeSelf) { _pouch.SetActive(true); } return; } _pouch = new GameObject("DoomAmmoPouch"); GameObject val = new GameObject("Box"); val.transform.SetParent(_pouch.transform, false); val.AddComponent<MeshFilter>().sharedMesh = BoxMesh(new Vector3(0.3f, 0.06f, 0.13f), 5f); _pouchRenderer = val.AddComponent<MeshRenderer>(); ((Renderer)_pouchRenderer).shadowCastingMode = (ShadowCastingMode)0; Shader val2 = Shader.Find("Unlit/Color") ?? Shader.Find("Legacy Shaders/Diffuse") ?? Shader.Find("Standard"); if ((Object)(object)val2 != (Object)null) { _plainBox = new Material(val2); ((Renderer)_pouchRenderer).sharedMaterials = (Material[])(object)new Material[2] { _plainBox, _plainBox }; } ApplyBoxSkin(flash: false); GameObject val3 = new GameObject("Counter"); val3.transform.SetParent(_pouch.transform, false); val3.transform.localPosition = new Vector3(0f, 0.0315f, 0f); val3.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); if (TextFont != null || _wadFont != null) { _pouchBitmap = val3.AddComponent<BitmapText>(); _pouchBitmap.Font = _wadFont ?? TextFont; _pouchBitmap.LineHeight = 0.0145f; _pouchBit