Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SuperVikingKart v0.0.4
plugins\SuperVikingKart.dll
Decompiled 2 weeks 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.GUI; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SuperVikingKart")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SuperVikingKart")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("688870bc-01cb-4450-aff0-29c44facc3a2")] [assembly: AssemblyFileVersion("0.0.4")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.4.0")] namespace SuperVikingKart; internal enum BuffTarget { Puller, Rider, Both } internal enum BlockType { Buff, Debuff, Mystery } internal enum BuffType { Buff, Debuff } internal class BuffDefinition { public string Name; public string StatusEffect; public BuffTarget Target; public BuffType Type; public BuffDefinition(string name, string statusEffect, BuffTarget target, BuffType type = BuffType.Buff) { Name = name; StatusEffect = statusEffect; Target = target; Type = type; } } internal class BuffBlockComponent : MonoBehaviour { public GameObject Visual; public BlockType BlockType; public GameObject CollectEffectPrefab; private const string ZdoKeyIsActive = "SuperVikingKart_BuffBlockActive"; private ZNetView _netView; private float _respawnTimer; private static readonly BuffDefinition[] Buffs = new BuffDefinition[13] { new BuffDefinition("Speed Boost", "SuperVikingKart_SpeedBoost", BuffTarget.Puller), new BuffDefinition("Stamina Regen", "SuperVikingKart_StaminaRegen", BuffTarget.Puller), new BuffDefinition("Stamina Burst", "SuperVikingKart_StaminaBurst", BuffTarget.Puller), new BuffDefinition("Ooze Bombs", "SuperVikingKart_OozeBombs", BuffTarget.Rider), new BuffDefinition("Bile Bombs", "SuperVikingKart_BileBombs", BuffTarget.Rider), new BuffDefinition("Smoke Bombs", "SuperVikingKart_SmokeBombs", BuffTarget.Rider), new BuffDefinition("Fire Arrows", "SuperVikingKart_FireArrows", BuffTarget.Rider), new BuffDefinition("Harpoon", "SuperVikingKart_Harpoon", BuffTarget.Rider), new BuffDefinition("Berserk", "SuperVikingKart_Berserk", BuffTarget.Rider), new BuffDefinition("Shield", "SuperVikingKart_Shield", BuffTarget.Both), new BuffDefinition("Health Regen", "SuperVikingKart_HealthRegen", BuffTarget.Both), new BuffDefinition("Health Burst", "SuperVikingKart_HealthBurst", BuffTarget.Both), new BuffDefinition("Living Dead", "SuperVikingKart_LivingDead", BuffTarget.Both) }; private static readonly BuffDefinition[] Debuffs = new BuffDefinition[10] { new BuffDefinition("Frost", "SuperVikingKart_Frost", BuffTarget.Puller, BuffType.Debuff), new BuffDefinition("Tarred", "SuperVikingKart_Tarred", BuffTarget.Puller, BuffType.Debuff), new BuffDefinition("Bouncy", "SuperVikingKart_Bounce", BuffTarget.Puller, BuffType.Debuff), new BuffDefinition("Poison", "SuperVikingKart_Poison", BuffTarget.Rider, BuffType.Debuff), new BuffDefinition("Burning", "SuperVikingKart_Burn", BuffTarget.Rider, BuffType.Debuff), new BuffDefinition("Stagger", "SuperVikingKart_Stagger", BuffTarget.Rider, BuffType.Debuff), new BuffDefinition("Disarm", "SuperVikingKart_Disarm", BuffTarget.Rider, BuffType.Debuff), new BuffDefinition("Weak", "SuperVikingKart_Weak", BuffTarget.Both, BuffType.Debuff), new BuffDefinition("Shock", "SuperVikingKart_Shock", BuffTarget.Both, BuffType.Debuff), new BuffDefinition("Blind", "SuperVikingKart_Blind", BuffTarget.Both, BuffType.Debuff) }; public static readonly BuffDefinition[] AllEffects = Buffs.Concat(Debuffs).ToArray(); private BuffDefinition[] ActiveEffects => BlockType switch { BlockType.Buff => Buffs, BlockType.Debuff => Debuffs, BlockType.Mystery => AllEffects, _ => Buffs, }; private void Awake() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) _netView = ((Component)this).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)_netView) || _netView.GetZDO() == null) { SuperVikingKart.DebugLog("BuffBlock Awake - no ZNetView or ZDO, disabling"); ((Behaviour)this).enabled = false; return; } SuperVikingKart.DebugLog($"BuffBlock Awake - ZDO: {_netView.GetZDO().m_uid}, Owner: {_netView.IsOwner()}"); _netView.Register<int, ZDOID>("SuperVikingKart_RPC_RequestCollection", (Action<long, int, ZDOID>)RPC_RequestCollection); _netView.Register<int>("SuperVikingKart_RPC_BuffBlockCollected", (Action<long, int>)RPC_BuffBlockCollected); _netView.Register("SuperVikingKart_RPC_BuffBlockRespawn", (Action<long>)RPC_BuffBlockRespawn); _netView.Register<int, ZDOID>("SuperVikingKart_RPC_ApplyBuff", (Action<long, int, ZDOID>)RPC_ApplyBuff); bool @bool = _netView.GetZDO().GetBool("SuperVikingKart_BuffBlockActive", true); SuperVikingKart.DebugLog($"BuffBlock Awake - IsActive: {@bool}"); SetVisual(@bool); } private void Update() { if (_netView.IsOwner() && !IsActive()) { _respawnTimer -= Time.deltaTime; if (_respawnTimer <= 0f) { SuperVikingKart.DebugLog("BuffBlock - Respawn timer expired, sending respawn RPC"); _netView.InvokeRPC(ZNetView.Everybody, "SuperVikingKart_RPC_BuffBlockRespawn", Array.Empty<object>()); } } } public void OnBuffBlockTriggerEnter(Collider other) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog("BuffBlock trigger entered by: " + ((Object)other).name + " (parent: " + ((Object)((Component)other).transform.root).name + ")"); Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { SuperVikingKart.DebugLog("BuffBlock - No local player"); return; } SuperVikingKartComponent componentInParent = ((Component)other).GetComponentInParent<SuperVikingKartComponent>(); if (!Object.op_Implicit((Object)(object)componentInParent)) { SuperVikingKart.DebugLog("BuffBlock - No kart found on collider"); return; } if (!Object.op_Implicit((Object)(object)componentInParent.GetVagon())) { SuperVikingKart.DebugLog("BuffBlock - No vagon found on kart"); return; } Player puller = componentInParent.GetPuller(); SuperVikingKart.DebugLog("BuffBlock - Puller: " + (((puller != null) ? puller.GetPlayerName() : null) ?? "none") + ", LocalPlayer: " + localPlayer.GetPlayerName()); if ((Object)(object)puller != (Object)(object)localPlayer) { SuperVikingKart.DebugLog("BuffBlock - Local player is not the puller, ignoring"); return; } ZNetView componentInParent2 = ((Component)componentInParent).GetComponentInParent<ZNetView>(); if (!Object.op_Implicit((Object)(object)componentInParent2)) { SuperVikingKart.DebugLog("BuffBlock - No ZNetView on kart"); return; } ZDOID uid = componentInParent2.GetZDO().m_uid; BuffDefinition[] array = ((componentInParent.GetRiderZDOID() == ZDOID.None) ? ActiveEffects.Where((BuffDefinition b) => b.Target == BuffTarget.Puller || b.Target == BuffTarget.Both).ToArray() : ActiveEffects); if (array.Length == 0) { SuperVikingKart.DebugLog("BuffBlock - No valid effects for current kart state, aborting"); return; } BuffDefinition value = array[Random.Range(0, array.Length)]; int num = Array.IndexOf(ActiveEffects, value); SuperVikingKart.DebugLog($"BuffBlock - Requesting collection! Effect: {ActiveEffects[num].Name} (index: {num}), kartId: {uid}"); _netView.InvokeRPC("SuperVikingKart_RPC_RequestCollection", new object[2] { num, uid }); } private void RPC_RequestCollection(long sender, int buffIndex, ZDOID kartId) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"BuffBlock RPC_RequestCollection - sender: {sender}, buffIndex: {buffIndex}, kartId: {kartId}, IsOwner: {_netView.IsOwner()}"); if (_netView.IsOwner()) { if (!IsActive()) { SuperVikingKart.DebugLog("BuffBlock RPC_RequestCollection - Already collected, rejecting"); return; } _netView.GetZDO().Set("SuperVikingKart_BuffBlockActive", false); _respawnTimer = SuperVikingKart.BuffBlockRespawnTimeConfig.Value; _netView.InvokeRPC(ZNetView.Everybody, "SuperVikingKart_RPC_ApplyBuff", new object[2] { buffIndex, kartId }); _netView.InvokeRPC(ZNetView.Everybody, "SuperVikingKart_RPC_BuffBlockCollected", new object[1] { buffIndex }); } } private void RPC_ApplyBuff(long sender, int buffIndex, ZDOID kartId) { //IL_0011: 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_007a: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"BuffBlock RPC_ApplyBuff - sender: {sender}, buffIndex: {buffIndex}, kartId: {kartId}"); BuffDefinition[] activeEffects = ActiveEffects; if (buffIndex < 0 || buffIndex >= activeEffects.Length) { Logger.LogWarning((object)$"BuffBlock RPC_ApplyBuff - Invalid buff index: {buffIndex}"); return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { SuperVikingKart.DebugLog("BuffBlock RPC_ApplyBuff - No local player"); return; } GameObject val = ZNetScene.instance.FindInstance(kartId); if (!Object.op_Implicit((Object)(object)val)) { SuperVikingKart.DebugLog($"BuffBlock RPC_ApplyBuff - Kart not found for ZDOID: {kartId}"); return; } SuperVikingKartComponent componentInChildren = val.GetComponentInChildren<SuperVikingKartComponent>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { SuperVikingKart.DebugLog("BuffBlock RPC_ApplyBuff - No SuperVikingKartComponent on kart"); return; } Vagon vagon = componentInChildren.GetVagon(); if (!Object.op_Implicit((Object)(object)vagon)) { SuperVikingKart.DebugLog("BuffBlock RPC_ApplyBuff - No vagon on kart"); return; } BuffDefinition buffDefinition = activeEffects[buffIndex]; bool flag = vagon.IsAttached((Character)(object)localPlayer); bool flag2 = (Object)(object)componentInChildren.GetRider() == (Object)(object)localPlayer; SuperVikingKart.DebugLog($"BuffBlock RPC_ApplyBuff - Player: {localPlayer.GetPlayerName()}, IsPuller: {flag}, IsRider: {flag2}, BuffTarget: {buffDefinition.Target}"); string text = buffDefinition.Target switch { BuffTarget.Puller => "Puller", BuffTarget.Rider => "Rider", BuffTarget.Both => "Both", _ => "Unknown", }; string text2 = ((buffDefinition.Type == BuffType.Debuff) ? "Oh no" : "Yeah"); switch (buffDefinition.Target) { case BuffTarget.Puller: if (flag) { ApplyToPlayer(localPlayer, buffDefinition); } if (flag || flag2) { ((Character)localPlayer).Message((MessageType)2, text2 + "! " + buffDefinition.Name + " for " + text + "!", 0, (Sprite)null); } break; case BuffTarget.Rider: if (flag2) { ApplyToPlayer(localPlayer, buffDefinition); } if (flag || flag2) { ((Character)localPlayer).Message((MessageType)2, text2 + "! " + buffDefinition.Name + " for " + text + "!", 0, (Sprite)null); } break; case BuffTarget.Both: if (flag || flag2) { ApplyToPlayer(localPlayer, buffDefinition); ((Character)localPlayer).Message((MessageType)2, text2 + "! " + buffDefinition.Name + " for " + text + "!", 0, (Sprite)null); } break; } } private void ApplyToPlayer(Player player, BuffDefinition buff) { if (Object.op_Implicit((Object)(object)player)) { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(buff.StatusEffect)); if ((Object)(object)statusEffect == (Object)null) { Logger.LogWarning((object)("BuffBlock ApplyToPlayer - Could not find status effect: " + buff.StatusEffect)); return; } SuperVikingKart.DebugLog("BuffBlock ApplyToPlayer - Applying " + buff.Name + " (" + buff.StatusEffect + ") to " + player.GetPlayerName()); ((Character)player).GetSEMan().AddStatusEffect(statusEffect, true, 0, 0f); } } private bool IsActive() { ZDO zDO = _netView.GetZDO(); if (zDO == null) { return false; } return zDO.GetBool("SuperVikingKart_BuffBlockActive", true); } private void SetVisual(bool active) { if (Object.op_Implicit((Object)(object)Visual)) { Visual.SetActive(active); } } private void RPC_BuffBlockCollected(long sender, int buffIndex) { //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) SuperVikingKart.DebugLog($"BuffBlock RPC_BuffBlockCollected - sender: {sender}, buffIndex: {buffIndex}, IsOwner: {_netView.IsOwner()}"); if (Object.op_Implicit((Object)(object)CollectEffectPrefab)) { Object.Instantiate<GameObject>(CollectEffectPrefab, Visual.transform.position, Quaternion.identity); } SetVisual(active: false); } private void RPC_BuffBlockRespawn(long sender) { SuperVikingKart.DebugLog($"BuffBlock RPC_BuffBlockRespawn - sender: {sender}, IsOwner: {_netView.IsOwner()}"); if (_netView.IsOwner()) { _netView.GetZDO().Set("SuperVikingKart_BuffBlockActive", true); } SetVisual(active: true); } } internal class BuffBlockTrigger : MonoBehaviour { public BuffBlockComponent BuffBlock; private readonly HashSet<Collider> _seen = new HashSet<Collider>(); private void OnTriggerEnter(Collider other) { if (_seen.Add(other) && Object.op_Implicit((Object)(object)BuffBlock)) { BuffBlock.OnBuffBlockTriggerEnter(other); } } private void OnDisable() { _seen.Clear(); } } internal class BuffBlockSpin : MonoBehaviour { public float RotationSpeed = 50f; public float BobSpeed = 2f; public float BobHeight = 0.15f; private Vector3 _startPosition; private void Start() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) _startPosition = ((Component)this).transform.localPosition; } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(Vector3.up, RotationSpeed * Time.deltaTime); float num = Mathf.Sin(Time.time * BobSpeed) * BobHeight; ((Component)this).transform.localPosition = _startPosition + Vector3.up * num; } } internal static class Commands { public static void Register() { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ForceBuffCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RaceCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RaceAdminCommand()); } } internal class ForceBuffCommand : ConsoleCommand { public override string Name => "svk_buff"; public override string Help => "Force a specific buff. Usage: svk_buff <name> or svk_buff list"; public override bool IsCheat => true; public override List<string> CommandOptionList() { List<string> list = new List<string> { "list" }; BuffDefinition[] allEffects = BuffBlockComponent.AllEffects; foreach (BuffDefinition buffDefinition in allEffects) { list.Add(buffDefinition.Name); } return list; } public override void Run(string[] args, Terminal context) { if (args.Length == 0) { context.AddString("Usage: svk_buff <name> or svk_buff list"); return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { context.AddString("No local player"); return; } BuffDefinition[] allEffects; if (args[0].ToLower() == "list") { context.AddString("Available effects:"); allEffects = BuffBlockComponent.AllEffects; foreach (BuffDefinition buffDefinition in allEffects) { context.AddString($" {buffDefinition.Name} ({buffDefinition.StatusEffect}) - {buffDefinition.Target} {buffDefinition.Type}"); } return; } string text = string.Join(" ", args).ToLower(); BuffDefinition buffDefinition2 = null; allEffects = BuffBlockComponent.AllEffects; foreach (BuffDefinition buffDefinition3 in allEffects) { if (buffDefinition3.Name.ToLower() == text || buffDefinition3.StatusEffect.ToLower() == text) { buffDefinition2 = buffDefinition3; break; } } if (buffDefinition2 == null) { context.AddString("Effect '" + text + "' not found. Use 'svk_buff list' to see available effects."); return; } StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(buffDefinition2.StatusEffect)); if ((Object)(object)statusEffect == (Object)null) { context.AddString("Status effect '" + buffDefinition2.StatusEffect + "' not found in ObjectDB"); return; } ((Character)localPlayer).GetSEMan().AddStatusEffect(statusEffect, true, 0, 0f); context.AddString($"Applied {buffDefinition2.Name} ({buffDefinition2.Type}) to {localPlayer.GetPlayerName()}"); } } internal class RaceCommand : ConsoleCommand { private Terminal _context; public override string Name => "svk_race"; public override string Help => "Race participation. Usage: svk_race <subcommand> [args]"; public override List<string> CommandOptionList() { List<string> list = new List<string> { "register", "leave", "start", "reset", "results", "list" }; foreach (Race allRace in RaceManager.GetAllRaces()) { list.Add(allRace.RaceId); } return list; } public override void Run(string[] args, Terminal context) { _context = context; if (args.Length == 0) { PrintUsage(); return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { context.AddString("No local player"); return; } switch (args[0].ToLower()) { case "list": ListRaces(); break; case "register": if (args.Length < 2) { context.AddString("Usage: svk_race register <raceId>"); } else { RegisterPlayer(localPlayer, args[1]); } break; case "leave": if (args.Length < 2) { context.AddString("Usage: svk_race leave <raceId>"); } else { LeaveRace(localPlayer, args[1]); } break; case "start": if (args.Length < 2) { context.AddString("Usage: svk_race start <raceId>"); } else { StartRace(args[1]); } break; case "reset": if (args.Length < 2) { context.AddString("Usage: svk_race reset <raceId>"); } else { ResetRace(args[1]); } break; case "results": if (args.Length < 2) { context.AddString("Usage: svk_race results <raceId>"); } else { ShowResults(args[1]); } break; default: RegisterPlayer(localPlayer, args[0]); break; } } private void PrintUsage() { _context.AddString("Usage: svk_race <subcommand> [args]"); _context.AddString(" list - List all races"); _context.AddString(" register <raceId> - Register for a race"); _context.AddString(" leave <raceId> - Leave a race"); _context.AddString(" start <raceId> - Start countdown"); _context.AddString(" reset <raceId> - Reset a race"); _context.AddString(" results <raceId> - Show results"); _context.AddString(" <raceId> - Shorthand for register"); } private void ListRaces() { int num = 0; foreach (Race allRace in RaceManager.GetAllRaces()) { _context.AddString($" [{allRace.RaceId}] \"{allRace.Name}\" State: {allRace.State}, Contestants: {allRace.Contestants.Count}"); num++; } if (num == 0) { _context.AddString("No active races"); } } private void RegisterPlayer(Player player, string raceId) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } if (race.State != 0) { _context.AddString("Race [" + raceId + "] is already underway"); return; } if (race.IsRegistered(((Character)player).GetZDOID())) { _context.AddString("Already registered for [" + raceId + "]"); return; } RaceManager.SendRegister(raceId, player.GetPlayerName(), ((Character)player).GetZDOID()); _context.AddString("Registered for [" + raceId + "]"); } private void LeaveRace(Player player, string raceId) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } if (!race.IsRegistered(((Character)player).GetZDOID())) { _context.AddString("Not registered for [" + raceId + "]"); return; } if (race.State == RaceState.Countdown) { _context.AddString("Cannot leave [" + raceId + "] during countdown"); return; } if (race.State == RaceState.Finished) { _context.AddString("Race [" + raceId + "] is already finished"); return; } RaceManager.SendUnregister(raceId, ((Character)player).GetZDOID()); _context.AddString((race.State == RaceState.Racing) ? ("Left race [" + raceId + "] - DNF") : ("Left race [" + raceId + "]")); } private void StartRace(string raceId) { Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } if (race.State != 0) { _context.AddString($"Race [{raceId}] is not idle (State: {race.State})"); return; } if (race.Contestants.Count == 0) { _context.AddString("Race [" + raceId + "] has no contestants"); return; } RaceManager.SendStartCountdown(raceId); _context.AddString("Race [" + raceId + "] countdown started"); } private void ResetRace(string raceId) { if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendReset(raceId); _context.AddString("Race [" + raceId + "] reset"); } private void ShowResults(string raceId) { Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); } else { _context.AddString(race.GetResultsText()); } } } internal class RaceAdminCommand : ConsoleCommand { private Terminal _context; public override string Name => "svk_race_admin"; public override string Help => "Admin race management. Usage: svk_race_admin <subcommand> [args]"; public override bool IsCheat => true; public override List<string> CommandOptionList() { return new List<string> { "create", "remove", "addplayer", "setname", "setlaps", "forcestart", "forcereset", "checkpoint", "lap", "finish", "state" }; } public override void Run(string[] args, Terminal context) { _context = context; if (args.Length == 0) { PrintUsage(); return; } switch (args[0].ToLower()) { case "create": { if (args.Length < 2) { context.AddString("Usage: svk_race_admin create <raceId> [laps] [name]"); break; } int result; int laps = ((args.Length <= 2 || !int.TryParse(args[2], out result)) ? 1 : result); string name = ((args.Length > 3) ? string.Join(" ", args, 3, args.Length - 3) : null); CreateRace(args[1], name, laps); break; } case "remove": if (args.Length < 2) { context.AddString("Usage: svk_race_admin remove <raceId>"); } else { RemoveRace(args[1]); } break; case "addplayer": if (args.Length < 3) { context.AddString("Usage: svk_race_admin addplayer <raceId> <playerName>"); } else { AddPlayer(args[1], args[2]); } break; case "setname": if (args.Length < 3) { context.AddString("Usage: svk_race_admin setname <raceId> <name>"); } else { SetName(args[1], string.Join(" ", args, 2, args.Length - 2)); } break; case "setlaps": if (args.Length < 3) { context.AddString("Usage: svk_race_admin setlaps <raceId> <count>"); } else { SetLaps(args[1], args[2]); } break; case "setdescription": if (args.Length < 3) { context.AddString("Usage: svk_race_admin setdescription <raceId> <description>"); } else { SetDescription(args[1], string.Join(" ", args, 2, args.Length - 2)); } break; case "forcestart": if (args.Length < 2) { context.AddString("Usage: svk_race_admin forcestart <raceId>"); } else { ForceStart(args[1]); } break; case "forcereset": if (args.Length < 2) { context.AddString("Usage: svk_race_admin forcereset <raceId>"); } else { ForceReset(args[1]); } break; case "checkpoint": if (args.Length < 3) { context.AddString("Usage: svk_race_admin checkpoint <raceId> <checkpointIndex> [playerName]"); } else { SimulateCheckpoint(args); } break; case "lap": if (args.Length < 2) { context.AddString("Usage: svk_race_admin lap <raceId> [playerName]"); } else { SimulateLap(args); } break; case "finish": if (args.Length < 2) { context.AddString("Usage: svk_race_admin finish <raceId> [playerName]"); } else { SimulateFinish(args); } break; case "state": if (args.Length < 2) { context.AddString("Usage: svk_race_admin state <raceId>"); } else { ShowState(args[1]); } break; default: PrintUsage(); break; } } private void PrintUsage() { _context.AddString("Usage: svk_race_admin <subcommand> [args]"); _context.AddString(" create <raceId> - Create a new race"); _context.AddString(" remove <raceId> - Remove a race"); _context.AddString(" addplayer <raceId> <playerName> - Add a player by name"); _context.AddString(" setname <raceId> <name> - Rename a race"); _context.AddString(" setlaps <raceId> <count> - Set lap count"); _context.AddString(" setdescription <raceId> <description> - Set lap count"); _context.AddString(" forcestart <raceId> - Start race regardless of state"); _context.AddString(" forcereset <raceId> - Reset race regardless of state"); _context.AddString(" lap <raceId> [playerName] - Simulate a lap completion"); _context.AddString(" finish <raceId> [playerName] - Simulate finishing all laps"); _context.AddString(" state <raceId> - Show detailed race state"); } private void CreateRace(string raceId, string name = null, int laps = 1) { if (RaceManager.GetRace(raceId) != null) { _context.AddString("Race [" + raceId + "] already exists"); return; } string text = (string.IsNullOrEmpty(name) ? raceId : name); RaceManager.SendCreateRace(raceId, text, laps); _context.AddString($"Race [{raceId}] created - \"{text}\" ({laps} laps)"); } private void RemoveRace(string raceId) { if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendRemoveRace(raceId); _context.AddString("Race [" + raceId + "] removed"); } private void AddPlayer(string raceId, string playerName) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } if (race.State != 0) { _context.AddString($"Race [{raceId}] is not idle (State: {race.State})"); return; } Player val = FindPlayerByName(playerName); if ((Object)(object)val == (Object)null) { _context.AddString("Player '" + playerName + "' not found"); return; } if (race.IsRegistered(((Character)val).GetZDOID())) { _context.AddString("Player '" + playerName + "' already registered"); return; } RaceManager.SendRegister(raceId, val.GetPlayerName(), ((Character)val).GetZDOID()); _context.AddString("Added " + val.GetPlayerName() + " to [" + raceId + "]"); } private void SetName(string raceId, string name) { if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendSetName(raceId, name); _context.AddString("Race [" + raceId + "] renamed to \"" + name + "\""); } private void SetLaps(string raceId, string countStr) { if (!int.TryParse(countStr, out var result) || result < 1) { _context.AddString("Invalid lap count"); return; } if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendSetLaps(raceId, result); _context.AddString($"Race [{raceId}] laps set to {result}"); } private void SetDescription(string raceId, string description) { if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendSetDescription(raceId, description); _context.AddString("Race [" + raceId + "] description set to \"" + description + "\""); } private void ForceStart(string raceId) { Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } if (race.Contestants.Count == 0) { _context.AddString("Race [" + raceId + "] has no contestants"); return; } RaceManager.SendState(raceId, RaceState.Idle); RaceManager.SendStartCountdown(raceId); _context.AddString("Race [" + raceId + "] force started"); } private void ForceReset(string raceId) { if (RaceManager.GetRace(raceId) == null) { _context.AddString("Race [" + raceId + "] not found"); return; } RaceManager.SendState(raceId, RaceState.Finished); RaceManager.SendReset(raceId); _context.AddString("Race [" + raceId + "] force reset"); } private void SimulateCheckpoint(string[] args) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) string text = args[1]; Race race = RaceManager.GetRace(text); if (race == null) { _context.AddString("Race [" + text + "] not found"); return; } if (race.State != RaceState.Racing) { _context.AddString($"Race [{text}] is not racing (State: {race.State})"); return; } if (!int.TryParse(args[2], out var result) || result < 0) { _context.AddString("Invalid checkpoint index"); return; } Player val = ((args.Length > 3) ? FindPlayerByName(args[3]) : Player.m_localPlayer); if ((Object)(object)val == (Object)null) { _context.AddString((args.Length > 3) ? ("Player '" + args[3] + "' not found") : "No local player"); return; } RaceContestant contestant = race.GetContestant(((Character)val).GetZDOID()); if (contestant == null) { _context.AddString("Player '" + val.GetPlayerName() + "' not in race [" + text + "]"); } else if (contestant.Finished) { _context.AddString("Player '" + val.GetPlayerName() + "' already finished"); } else { RaceManager.SendCheckpoint(text, ((Character)val).GetZDOID(), result); _context.AddString($"Checkpoint {result} recorded for {val.GetPlayerName()}"); } } private void SimulateLap(string[] args) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) string text = args[1]; Race race = RaceManager.GetRace(text); if (race == null) { _context.AddString("Race [" + text + "] not found"); return; } if (race.State != RaceState.Racing) { _context.AddString($"Race [{text}] is not racing (State: {race.State})"); return; } Player val = ((args.Length > 2) ? FindPlayerByName(args[2]) : Player.m_localPlayer); if ((Object)(object)val == (Object)null) { _context.AddString((args.Length > 2) ? ("Player '" + args[2] + "' not found") : "No local player"); return; } RaceContestant contestant = race.GetContestant(((Character)val).GetZDOID()); if (contestant == null) { _context.AddString("Player '" + val.GetPlayerName() + "' not in race [" + text + "]"); } else if (contestant.Finished) { _context.AddString("Player '" + val.GetPlayerName() + "' already finished"); } else { RaceManager.SendLap(text, ((Character)val).GetZDOID()); _context.AddString("Lap recorded for " + val.GetPlayerName()); } } private void SimulateFinish(string[] args) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) string text = args[1]; Race race = RaceManager.GetRace(text); if (race == null) { _context.AddString("Race [" + text + "] not found"); return; } if (race.State != RaceState.Racing) { _context.AddString($"Race [{text}] is not racing (State: {race.State})"); return; } Player val = ((args.Length > 2) ? FindPlayerByName(args[2]) : Player.m_localPlayer); if ((Object)(object)val == (Object)null) { _context.AddString((args.Length > 2) ? ("Player '" + args[2] + "' not found") : "No local player"); return; } RaceContestant contestant = race.GetContestant(((Character)val).GetZDOID()); if (contestant == null) { _context.AddString("Player '" + val.GetPlayerName() + "' not in race [" + text + "]"); } else if (contestant.Finished) { _context.AddString("Player '" + val.GetPlayerName() + "' already finished"); } else { int num = race.TotalLaps - contestant.CurrentLap; for (int i = 0; i < num; i++) { RaceManager.SendLap(text, ((Character)val).GetZDOID()); } _context.AddString($"Finished {val.GetPlayerName()} ({num} laps sent)"); } } private void ShowState(string raceId) { //IL_0224: Unknown result type (might be due to invalid IL or missing references) Race race = RaceManager.GetRace(raceId); if (race == null) { _context.AddString("Race [" + raceId + "] not found"); return; } _context.AddString("Race [" + race.RaceId + "] \"" + race.Name + "\""); _context.AddString($" State: {race.State}"); _context.AddString($" Laps: {race.TotalLaps}"); _context.AddString($" Contestants: {race.Contestants.Count}"); if (race.State == RaceState.Racing) { _context.AddString(" Elapsed: " + RaceUtils.FormatTime(ZNet.instance.m_netTime - race.RaceStartTime)); } foreach (RaceContestant item in race.GetLiveRanking()) { string arg2; if (item.IsDnf) { string arg = ((item.LastCheckpointIndex > 0) ? $", CP {item.LastCheckpointIndex}" : ""); arg2 = $"DNF - Lap {item.CurrentLap}/{race.TotalLaps}{arg}"; } else if (item.Finished) { arg2 = $"P{item.Position} - {RaceUtils.FormatTime(item.FinishTime)}"; } else if (race.State == RaceState.Racing) { string text = ((item.LastCheckpointIndex > 0) ? $", CP {item.LastCheckpointIndex}" : ""); arg2 = $"Lap {item.CurrentLap}/{race.TotalLaps}{text} ({RaceUtils.FormatTime(item.LastCheckpointTime)})"; } else { arg2 = "Registered"; } _context.AddString($" {item.PlayerName} ({item.PlayerId}): {arg2}"); } } private Player FindPlayerByName(string name) { string value = name.ToLower(); foreach (Player allPlayer in Player.GetAllPlayers()) { if (allPlayer.GetPlayerName().ToLower().Contains(value)) { return allPlayer; } } return null; } } internal static class KartPiece { public static void CloneCart() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) PieceConfig val = new PieceConfig(); val.Name = "Super Viking Kart"; val.Description = "Mountable cart. Get ready to race."; val.PieceTable = PieceTables.Hammer; val.Category = PieceCategories.Misc; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Wood", 4, 0, true) }; CustomPiece val2 = new CustomPiece("SuperVikingKart", "Cart", val); val2.Piece.m_canBeRemoved = true; PieceManager.Instance.AddPiece(val2); Transform transform = val2.PiecePrefab.transform; Object.DestroyImmediate((Object)(object)((Component)transform.Find("load")).gameObject); GameObject val3 = new GameObject("AttachPointPlayer"); val3.transform.SetParent(transform, false); val3.transform.SetAsFirstSibling(); val3.transform.localPosition = Vector3.up * 0.5f; GameObject gameObject = ((Component)transform.Find("Container")).gameObject; Object.DestroyImmediate((Object)(object)gameObject.GetComponent<Container>()); gameObject.AddComponent<SuperVikingKartComponent>().AttachPoint = val3.transform; SuperVikingKart.DebugLog("SuperVikingKart prefab registered"); } } internal static class BuffBlockPieces { public static void CreateBuffBlock() { CreateBlock("BuffBlock", "Buff Block", "Drive through for a random buff!", CreateBuffBlockMaterial(), BlockType.Buff); SuperVikingKart.DebugLog("BuffBlock prefab registered"); } public static void CreateDebuffBlock() { CreateBlock("DebuffBlock", "Debuff Block", "Drive through for a random debuff!", CreateDebuffBlockMaterial(), BlockType.Debuff); SuperVikingKart.DebugLog("DebuffBlock prefab registered"); } public static void CreateMysteryBlock() { CreateBlock("MysteryBlock", "Mystery Block", "Drive through for a mystery effect!", CreateMysteryBlockMaterial(), BlockType.Mystery); SuperVikingKart.DebugLog("MysteryBlock prefab registered"); } private static void CreateBlock(string prefabName, string displayName, string description, Material material, BlockType blockType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0054: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown GameObject val = new GameObject(prefabName); val.layer = LayerMask.NameToLayer("piece_nonsolid"); val.SetActive(false); ZNetView obj = val.AddComponent<ZNetView>(); obj.m_persistent = true; obj.m_syncInitialScale = true; Piece obj2 = val.AddComponent<Piece>(); obj2.m_canBeRemoved = true; obj2.m_craftingStation = Cache.GetPrefab<CraftingStation>(CraftingStations.Workbench); BoxCollider obj3 = val.AddComponent<BoxCollider>(); obj3.center = Vector3.up * 1f; obj3.size = Vector3.one * 0.8f; GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val2).name = "Visual"; val2.transform.SetParent(val.transform, false); val2.transform.localPosition = Vector3.up * 1.5f; val2.transform.localScale = Vector3.one * 0.8f; ((Renderer)val2.GetComponent<MeshRenderer>()).material = material; BoxCollider component = val2.GetComponent<BoxCollider>(); ((Collider)component).isTrigger = true; component.size = Vector3.one * 1.5f; Rigidbody obj4 = val2.AddComponent<Rigidbody>(); obj4.isKinematic = true; obj4.useGravity = false; val2.AddComponent<BuffBlockSpin>(); BuffBlockComponent buffBlockComponent = val.AddComponent<BuffBlockComponent>(); buffBlockComponent.Visual = val2; buffBlockComponent.BlockType = blockType; GameObject prefab = PrefabManager.Instance.GetPrefab("vfx_Place_chest"); buffBlockComponent.CollectEffectPrefab = prefab; val2.AddComponent<BuffBlockTrigger>().BuffBlock = buffBlockComponent; Sprite icon = RenderManager.Instance.Render(val, RenderManager.IsometricRotation); PieceConfig val3 = new PieceConfig(); val3.Name = displayName; val3.Description = description; val3.PieceTable = PieceTables.Hammer; val3.Category = PieceCategories.Misc; val3.Icon = icon; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Wood", 1, 0, true) }; CustomPiece val4 = new CustomPiece(val, false, val3); PieceManager.Instance.AddPiece(val4); val.SetActive(true); } private static Material CreateBuffBlockMaterial() { //IL_000f: 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_0028: Unknown result type (might be due to invalid IL or missing references) return CreateBlockMaterial(new Color(0.85f, 0.85f, 0f), new Color(0.6f, 0.5f, 0f), Color.black); } private static Material CreateDebuffBlockMaterial() { //IL_000f: 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_0028: Unknown result type (might be due to invalid IL or missing references) return CreateBlockMaterial(new Color(0.8f, 0.2f, 0.2f), new Color(0.6f, 0.1f, 0.1f), Color.black); } private static Material CreateMysteryBlockMaterial() { //IL_000f: 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_0028: Unknown result type (might be due to invalid IL or missing references) return CreateBlockMaterial(new Color(0.6f, 0.2f, 0.8f), new Color(0.4f, 0.1f, 0.5f), Color.black); } private static Material CreateBlockMaterial(Color bgColor, Color borderColor, Color markColor) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0155: 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) if (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(64, 64); Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < array.Length; i++) { array[i] = bgColor; } for (int j = 0; j < 64; j++) { for (int k = 0; k < 64; k++) { if (j < 4 || j >= 60 || k < 4 || k >= 60) { array[k * 64 + j] = borderColor; } } } for (int l = 22; l < 42; l++) { for (int m = 44; m < 52; m++) { array[m * 64 + l] = markColor; } } for (int n = 36; n < 42; n++) { for (int num = 36; num < 44; num++) { array[num * 64 + n] = markColor; } } for (int num2 = 28; num2 < 42; num2++) { for (int num3 = 28; num3 < 36; num3++) { array[num3 * 64 + num2] = markColor; } } for (int num4 = 28; num4 < 36; num4++) { for (int num5 = 20; num5 < 28; num5++) { array[num5 * 64 + num4] = markColor; } } for (int num6 = 28; num6 < 36; num6++) { for (int num7 = 10; num7 < 18; num7++) { array[num7 * 64 + num6] = markColor; } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; Material val2 = new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = new Color(0.8f, 0.8f, 0.8f) }; val2.SetFloat("_RippleDistance", 0f); val2.SetFloat("_ValueNoise", 0f); val2.SetFloat("_ValueNoiseVertex", 0f); val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", bgColor * 0.3f); return val2; } } internal static class RaceBoardPiece { public static void CreateRaceBoard() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Expected O, but got Unknown //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Expected O, but got Unknown //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Expected O, but got Unknown GameObject val = new GameObject("RaceBoard"); val.layer = LayerMask.NameToLayer("piece"); val.SetActive(false); ZNetView obj = val.AddComponent<ZNetView>(); obj.m_persistent = true; obj.m_syncInitialScale = true; Piece obj2 = val.AddComponent<Piece>(); obj2.m_canBeRemoved = true; obj2.m_craftingStation = Cache.GetPrefab<CraftingStation>(CraftingStations.Workbench); GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj3).name = "BoardVisual"; obj3.transform.SetParent(val.transform, false); obj3.transform.localPosition = new Vector3(0f, 2.6f, 0f); obj3.transform.localScale = new Vector3(2.4f, 2.8f, 0.1f); Object.DestroyImmediate((Object)(object)obj3.GetComponent<BoxCollider>()); ((Renderer)obj3.GetComponent<MeshRenderer>()).material = CreateRaceBoardMaterial(); GameObject val2 = new GameObject("StatusDisplay"); val2.transform.SetParent(val.transform, false); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; TextMeshPro val3 = val2.AddComponent<TextMeshPro>(); ((TMP_Text)val3).font = Cache.GetPrefab<TMP_FontAsset>("Valheim-AveriaSansLibre"); ((TMP_Text)val3).alignment = (TextAlignmentOptions)257; ((TMP_Text)val3).fontSize = 1f; ((Graphic)val3).color = Color.white; ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; ((TMP_Text)val3).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((TMP_Text)val3).rectTransform.anchorMin = new Vector2(0.5f, 0.5f); ((TMP_Text)val3).rectTransform.anchorMax = new Vector2(0.5f, 0.5f); ((TMP_Text)val3).rectTransform.sizeDelta = new Vector2(2f, 2.7f); ((TMP_Text)val3).rectTransform.anchoredPosition3D = new Vector3(0f, 2.4f, -0.06f); GameObject val4 = new GameObject("ButtonRow"); val4.transform.SetParent(val.transform, false); val4.transform.localPosition = Vector3.zero; GameObject go = CreateButtonObject("RegisterButton", val4.transform, new Vector3(-0.9f, 1.25f, -0.06f), "Register"); GameObject go2 = CreateButtonObject("StartButton", val4.transform, new Vector3(-0.3f, 1.25f, -0.06f), "Start"); GameObject go3 = CreateButtonObject("ResetButton", val4.transform, new Vector3(0.3f, 1.25f, -0.06f), "Reset"); GameObject go4 = CreateButtonObject("AdminButton", val4.transform, new Vector3(0.9f, 1.25f, -0.06f), "Admin"); BoxCollider obj4 = val.AddComponent<BoxCollider>(); obj4.center = Vector3.zero; obj4.size = new Vector3(0.01f, 0.01f, 0.01f); BoxCollider obj5 = val.AddComponent<BoxCollider>(); obj5.center = new Vector3(0f, 2.6f, 0f); obj5.size = new Vector3(2.4f, 2.8f, 0.1f); BoxCollider obj6 = val.AddComponent<BoxCollider>(); obj6.center = new Vector3(0f, 2.6f, 0f); obj6.size = new Vector3(2.4f, 2.8f, 0.1f); ((Collider)obj6).isTrigger = true; RaceBoardComponent raceBoardComponent = val.AddComponent<RaceBoardComponent>(); raceBoardComponent.StatusDisplay = val3; raceBoardComponent.ButtonRow = val4; raceBoardComponent.RegisterButton = WireButton(go, RaceBoardButtonType.Register, raceBoardComponent); raceBoardComponent.StartButton = WireButton(go2, RaceBoardButtonType.Start, raceBoardComponent); raceBoardComponent.ResetButton = WireButton(go3, RaceBoardButtonType.Reset, raceBoardComponent); raceBoardComponent.AdminButton = WireButton(go4, RaceBoardButtonType.Admin, raceBoardComponent); Sprite icon = RenderManager.Instance.Render(val, RenderManager.IsometricRotation); PieceManager instance = PieceManager.Instance; PieceConfig val5 = new PieceConfig(); val5.Name = "Race Board"; val5.Description = "Place to configure and manage a race. Shows you race statistics in real time."; val5.PieceTable = PieceTables.Hammer; val5.Category = PieceCategories.Misc; val5.Icon = icon; val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Stone", 2, 0, true) }; instance.AddPiece(new CustomPiece(val, false, val5)); val.SetActive(true); SuperVikingKart.DebugLog("RaceBoard prefab registered"); } private static Material CreateRaceBoardMaterial() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_008e: 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 (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(64, 64); Color[] array = (Color[])(object)new Color[4096]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.15f, 0.1f, 0.05f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.6f, 0.4f, 0.1f); for (int i = 0; i < array.Length; i++) { array[i] = val2; } for (int j = 0; j < 64; j++) { for (int k = 0; k < 64; k++) { if (j < 3 || j >= 61 || k < 3 || k >= 61) { array[k * 64 + j] = val3; } } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; return new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = Color.white }; } private static GameObject CreateButtonObject(string name, Transform parent, Vector3 localPos, string label) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.transform.localScale = Vector3.one; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "Visual"; obj.transform.SetParent(val.transform, false); obj.transform.localScale = new Vector3(0.58f, 0.18f, 0.06f); Object.DestroyImmediate((Object)(object)obj.GetComponent<BoxCollider>()); ((Renderer)obj.GetComponent<MeshRenderer>()).material = CreateButtonMaterial(); val.AddComponent<BoxCollider>().size = new Vector3(0.58f, 0.18f, 0.12f); GameObject val2 = new GameObject("Label"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = new Vector3(0f, 0f, -0.04f); val2.transform.localScale = Vector3.one; TextMeshPro obj2 = val2.AddComponent<TextMeshPro>(); ((TMP_Text)obj2).font = Cache.GetPrefab<TMP_FontAsset>("Valheim-AveriaSansLibre"); ((TMP_Text)obj2).text = label; ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj2).fontSize = 1f; ((Graphic)obj2).color = Color.white; ((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)obj2).rectTransform.sizeDelta = new Vector2(0.54f, 0.16f); ((TMP_Text)obj2).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((TMP_Text)obj2).rectTransform.anchorMin = new Vector2(0.5f, 0.5f); ((TMP_Text)obj2).rectTransform.anchorMax = new Vector2(0.5f, 0.5f); ((TMP_Text)obj2).rectTransform.anchoredPosition = Vector2.zero; return val; } private static Material CreateButtonMaterial() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_008e: 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 (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(32, 16); Color[] array = (Color[])(object)new Color[512]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.2f, 0.12f, 0.04f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.55f, 0.35f, 0.08f); for (int i = 0; i < array.Length; i++) { array[i] = val2; } for (int j = 0; j < 32; j++) { for (int k = 0; k < 16; k++) { if (j < 2 || j >= 30 || k < 2 || k >= 14) { array[k * 32 + j] = val3; } } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; return new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = Color.white }; } private static RaceBoardButton WireButton(GameObject go, RaceBoardButtonType type, RaceBoardComponent board) { RaceBoardButton raceBoardButton = go.AddComponent<RaceBoardButton>(); raceBoardButton.ButtonType = type; raceBoardButton.Board = board; return raceBoardButton; } } internal static class RaceLinePiece { public static void CreateRaceLine() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RaceLine"); val.layer = LayerMask.NameToLayer("piece"); val.SetActive(false); ZNetView obj = val.AddComponent<ZNetView>(); obj.m_persistent = true; obj.m_syncInitialScale = true; Piece obj2 = val.AddComponent<Piece>(); obj2.m_canBeRemoved = true; obj2.m_craftingStation = Cache.GetPrefab<CraftingStation>(CraftingStations.Workbench); GameObject val2 = new GameObject("PlaceCollider"); val2.transform.SetParent(val.transform, false); BoxCollider obj3 = val2.AddComponent<BoxCollider>(); obj3.center = Vector3.zero; obj3.size = new Vector3(6f, 0.001f, 0.001f); GameObject val3 = new GameObject("TriggerCollider"); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = new Vector3(0f, 0f, 0f); BoxCollider obj4 = val3.AddComponent<BoxCollider>(); ((Collider)obj4).isTrigger = true; obj4.size = new Vector3(6f, 6f, 1f); Rigidbody obj5 = val3.AddComponent<Rigidbody>(); obj5.isKinematic = true; obj5.useGravity = false; CreatePost("PostLeft", val.transform, new Vector3(-3f, 1.5f, 0f)); CreatePost("PostRight", val.transform, new Vector3(3f, 1.5f, 0f)); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val4).name = "GroundQuad"; val4.transform.SetParent(val.transform, false); val4.transform.localPosition = new Vector3(0f, 0.02f, 0f); val4.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); val4.transform.localScale = new Vector3(6f, 1f, 1f); Object.DestroyImmediate((Object)(object)val4.GetComponent<MeshCollider>()); Material val5 = CreateChequeredMaterial(); if ((Object)(object)val5 != (Object)null) { val5.mainTextureScale = new Vector2(val4.transform.localScale.x / val4.transform.localScale.z, 1f); } ((Renderer)val4.GetComponent<MeshRenderer>()).material = val5; GameObject obj6 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj6).name = "DirectionArrow"; obj6.transform.SetParent(val.transform, false); obj6.transform.localPosition = new Vector3(0f, 0.03f, 0.6f); obj6.transform.localRotation = Quaternion.Euler(90f, 270f, 0f); obj6.transform.localScale = new Vector3(1f, 1f, 1f); Object.DestroyImmediate((Object)(object)obj6.GetComponent<MeshCollider>()); ((Renderer)obj6.GetComponent<MeshRenderer>()).material = CreateArrowMaterial(); GameObject val6 = new GameObject("Label"); val6.transform.SetParent(val.transform, false); val6.transform.localPosition = Vector3.zero; val6.transform.localScale = Vector3.one; TextMeshPro val7 = val6.AddComponent<TextMeshPro>(); ((TMP_Text)val7).font = Cache.GetPrefab<TMP_FontAsset>("Valheim-Norse"); ((TMP_Text)val7).alignment = (TextAlignmentOptions)514; ((TMP_Text)val7).fontSize = 3f; ((Graphic)val7).color = Color.black; ((TMP_Text)val7).fontStyle = (FontStyles)1; ((TMP_Text)val7).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)val7).overflowMode = (TextOverflowModes)0; ((TMP_Text)val7).rectTransform.sizeDelta = new Vector2(6f, 1.5f); ((TMP_Text)val7).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((TMP_Text)val7).rectTransform.anchorMin = new Vector2(0.5f, 0.5f); ((TMP_Text)val7).rectTransform.anchorMax = new Vector2(0.5f, 0.5f); ((TMP_Text)val7).rectTransform.anchoredPosition3D = new Vector3(0f, 3f, -0.05f); GameObject obj7 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj7).name = "Banner"; obj7.transform.SetParent(val.transform, false); obj7.transform.localPosition = new Vector3(0f, 3f, 0f); obj7.transform.localScale = new Vector3(6f, 0.4f, 0.01f); ((Renderer)obj7.GetComponent<MeshRenderer>()).material = CreateBannerMaterial(); RaceLineComponent raceLineComponent = val.AddComponent<RaceLineComponent>(); raceLineComponent.Label = val7; val3.AddComponent<RaceLineTrigger>().Line = raceLineComponent; val.transform.localScale = new Vector3(1.2f, 1.2f, 1f); Sprite icon = RenderManager.Instance.Render(val, RenderManager.IsometricRotation); PieceManager instance = PieceManager.Instance; PieceConfig val8 = new PieceConfig(); val8.Name = "Race Line"; val8.Description = "Start and/or finish line for a race. Place the arrow facing the direction of travel."; val8.PieceTable = PieceTables.Hammer; val8.Category = PieceCategories.Misc; val8.Icon = icon; val8.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Wood", 2, 0, true) }; instance.AddPiece(new CustomPiece(val, false, val8)); val.SetActive(true); SuperVikingKart.DebugLog("RaceLine prefab registered"); } private static void CreatePost(string name, Transform parent, Vector3 localPos) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPos; obj.transform.localScale = new Vector3(0.15f, 1.5f, 0.15f); ((Renderer)obj.GetComponent<MeshRenderer>()).material = CreatePostMaterial(); } private static Material CreateChequeredMaterial() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(64, 64); Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = i / 8; int num2 = j / 8; array[j * 64 + i] = (((num + num2) % 2 == 0) ? Color.white : Color.black); } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; return new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = new Color(0.6f, 0.6f, 0.6f) }; } private static Material CreateArrowMaterial() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < array.Length; i++) { array[i] = new Color(1f, 0.6f, 0f, 0f); } for (int j = 2; j <= 17; j++) { for (int k = 12; k <= 19; k++) { array[k * 32 + j] = new Color(1f, 0.6f, 0f, 1f); } } for (int l = 18; l <= 29; l++) { int num = 29 - l; int num2 = Mathf.RoundToInt(15.5f - (float)num); int num3 = Mathf.RoundToInt(15.5f + (float)num); for (int m = num2; m <= num3; m++) { if (m >= 0 && m < 32) { array[m * 32 + l] = new Color(1f, 0.6f, 0f, 1f); } } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; Material val2 = new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = new Color(0.6f, 0.6f, 0.6f) }; val2.SetFloat("_Cutoff", 0.1f); return val2; } private static Material CreatePostMaterial() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(4, 4); Color[] array = (Color[])(object)new Color[16]; for (int i = 0; i < 16; i++) { array[i] = new Color(0.9f, 0.85f, 0.1f); } val.SetPixels(array); val.Apply(); return new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = new Color(0.6f, 0.6f, 0.6f) }; } private static Material CreateBannerMaterial() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return null; } Texture2D val = new Texture2D(64, 16); Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 16; j++) { array[j * 64 + i] = ((i / 8 % 2 == 0) ? Color.red : Color.white); } } val.SetPixels(array); val.Apply(); ((Texture)val).filterMode = (FilterMode)0; return new Material(Cache.GetPrefab<Shader>("Custom/Piece")) { mainTexture = (Texture)(object)val, color = new Color(0.6f, 0.6f, 0.6f) }; } } internal class SuperVikingKartComponent : MonoBehaviour, Hoverable, Interactable { public static readonly List<SuperVikingKartComponent> Instances = new List<SuperVikingKartComponent>(); public string Name = "SuperVikingKartAttach"; public float UseDistance = 2f; public Transform AttachPoint; private const string ZdoKeyAttachedPlayer = "SuperVikingKart_AttachedPlayer"; private const string ZdoKeyColorR = "SuperVikingKart_ColorR"; private const string ZdoKeyColorG = "SuperVikingKart_ColorG"; private const string ZdoKeyColorB = "SuperVikingKart_ColorB"; private ZNetView _netView; private Vagon _vagon; private Renderer[] _kartRenderers; private float _lastSitTime; private Player _attachedPlayerLocal; public void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) Instances.Add(this); _netView = ((Component)this).gameObject.GetComponentInParent<ZNetView>(); if (!Object.op_Implicit((Object)(object)_netView) || _netView.GetZDO() == null) { SuperVikingKart.DebugLog("Kart Awake - no ZNetView or ZDO, disabling"); ((Behaviour)this).enabled = false; return; } SuperVikingKart.DebugLog($"Kart Awake - ZDO: {_netView.GetZDO().m_uid}, Owner: {_netView.IsOwner()}"); _netView.Register<ZDOID>("SuperVikingKart_RPC_Attach", (Action<long, ZDOID>)RPC_Attach); _netView.Register("SuperVikingKart_RPC_Detach", (Action<long>)RPC_Detach); _netView.Register<float, float, float>("SuperVikingKart_RPC_SetColor", (Action<long, float, float, float>)RPC_SetColor); _netView.Register<Vector3, float>("SuperVikingKart_RPC_KartDestroyed", (Action<long, Vector3, float>)RPC_KartDestroyed); if (_netView.IsOwner()) { ZDO zDO = _netView.GetZDO(); ZDOID zDOID = zDO.GetZDOID("SuperVikingKart_AttachedPlayer"); if (zDOID != ZDOID.None && !Object.op_Implicit((Object)(object)ZNetScene.instance.FindInstance(zDOID))) { SuperVikingKart.DebugLog($"Kart Awake - Clearing stale attachment: {zDOID}"); zDO.Set("SuperVikingKart_AttachedPlayer", ZDOID.None); } } _vagon = ((Component)this).GetComponentInParent<Vagon>(); _vagon.m_baseMass = 10f; _vagon.SetMass(_vagon.m_baseMass); _kartRenderers = ((Component)_vagon).GetComponentsInChildren<Renderer>(true); ApplyColor(GetCurrentColor()); } public void Update() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_attachedPlayerLocal)) { if (!Object.op_Implicit((Object)(object)AttachPoint)) { SuperVikingKart.DebugLog("Kart Update - AttachPoint lost, detaching"); Detach(); } else if (ZInput.GetButtonDown("Jump") || ((Character)_attachedPlayerLocal).IsDead()) { SuperVikingKart.DebugLog(string.Format("Kart Update - Detaching (Jump: {0}, Dead: {1})", ZInput.GetButtonDown("Jump"), ((Character)_attachedPlayerLocal).IsDead())); Detach(); } else { ((Component)_attachedPlayerLocal).transform.position = AttachPoint.position; } } } private void OnDestroy() { Instances.Remove(this); SuperVikingKart.DebugLog("Kart OnDestroy"); Detach(); } private void Attach(Player player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"Kart Attach - Player: {player.GetPlayerName()}, ZDOID: {((Character)player).GetZDOID()}"); _attachedPlayerLocal = player; if (Object.op_Implicit((Object)(object)_netView) && _netView.GetZDO() != null) { _netView.InvokeRPC("SuperVikingKart_RPC_Attach", new object[1] { ((Character)player).GetZDOID() }); } } private void Detach() { Player attachedPlayerLocal = _attachedPlayerLocal; SuperVikingKart.DebugLog("Kart Detach - Player: " + (((attachedPlayerLocal != null) ? attachedPlayerLocal.GetPlayerName() : null) ?? "none")); _attachedPlayerLocal = null; if (Object.op_Implicit((Object)(object)_netView) && _netView.GetZDO() != null) { _netView.InvokeRPC("SuperVikingKart_RPC_Detach", Array.Empty<object>()); } } private void RPC_Attach(long sender, ZDOID playerId) { //IL_000b: 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) SuperVikingKart.DebugLog($"Kart RPC_Attach - sender: {sender}, playerId: {playerId}, IsOwner: {_netView.IsOwner()}"); ZDO zDO = _netView.GetZDO(); if (zDO != null && _netView.IsOwner()) { zDO.Set("SuperVikingKart_AttachedPlayer", playerId); } } private void RPC_Detach(long sender) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"Kart RPC_Detach - sender: {sender}, IsOwner: {_netView.IsOwner()}"); ZDO zDO = _netView.GetZDO(); if (zDO != null && _netView.IsOwner()) { zDO.Set("SuperVikingKart_AttachedPlayer", ZDOID.None); } } public Color GetCurrentColor() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ZNetView netView = _netView; ZDO val = ((netView != null) ? netView.GetZDO() : null); if (val == null) { return Color.white; } return new Color(val.GetFloat("SuperVikingKart_ColorR", 1f), val.GetFloat("SuperVikingKart_ColorG", 1f), val.GetFloat("SuperVikingKart_ColorB", 1f)); } internal void ApplyColor(Color color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (_kartRenderers == null) { return; } MaterialPropertyBlock val = new MaterialPropertyBlock(); Renderer[] kartRenderers = _kartRenderers; foreach (Renderer val2 in kartRenderers) { if (Object.op_Implicit((Object)(object)val2)) { val2.GetPropertyBlock(val); val.SetColor("_Color", color); val2.SetPropertyBlock(val); } } } public void SetColor(Color color) { //IL_0005: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"Kart SetColor - {color}"); _netView.InvokeRPC(ZNetView.Everybody, "SuperVikingKart_RPC_SetColor", new object[3] { color.r, color.g, color.b }); } private void RPC_SetColor(long sender, float r, float g, float b) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) SuperVikingKart.DebugLog($"Kart RPC_SetColor - sender: {sender}, rgb: ({r},{g},{b})"); Color color = default(Color); ((Color)(ref color))..ctor(r, g, b); if (_netView.IsOwner()) { ZDO zDO = _netView.GetZDO(); if (zDO != null) { zDO.Set("SuperVikingKart_ColorR", r); zDO.Set("SuperVikingKart_ColorG", g); zDO.Set("SuperVikingKart_ColorB", b); } } ApplyColor(color); } private void RPC_KartDestroyed(long sender, Vector3 position, float rotY) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) SuperVikingKart.DebugLog($"RPC_KartDestroyed - position: {position}, rotY: {rotY}"); GameObject val = new GameObject("KartRespawnComponent"); val.transform.position = position + Vector3.up * 0.5f; val.layer = LayerMask.NameToLayer("character"); val.AddComponent<KartRespawnComponent>().Setup(SuperVikingKart.KartRespawnTimeConfig.Value); } public Vagon GetVagon() { return _vagon; } public Player GetPuller() { if (!Object.op_Implicit((Object)(object)_vagon)) { return null; } foreach (Player allPlayer in Player.GetAllPlayers()) { if (_vagon.IsAttached((Character)(object)allPlayer)) { return allPlayer; } } return null; } public Player GetRiderLocal() { return _attachedPlayerLocal; } public ZDOID GetRiderZDOID() { //IL_002e: 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_0042: Unknown result type (might be due to invalid IL or missing references) ZNetView netView = _netView; ZDOID? obj; if (netView == null) { obj = null; } else { ZDO zDO = netView.GetZDO(); obj = ((zDO != null) ? new ZDOID?(zDO.GetZDOID("SuperVikingKart_AttachedPlayer")) : null); } return (ZDOID)(((??)obj) ?? ZDOID.None); } public Player GetRider() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) ZDOID riderZDOID = GetRiderZDOID(); if (riderZDOID == ZDOID.None) { return null; } GameObject val = ZNetScene.instance.FindInstance(riderZDOID); if (!Object.op_Implicit((Object)(object)val)) { return null; } return val.GetComponent<Player>(); } private bool IsInUse() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return GetRiderZDOID() != ZDOID.None; } public bool Interact(Humanoid human, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((human is Player) ? human : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } if (!Object.op_Implicit((Object)(object)AttachPoint)) { return false; } if (!InUseDistance((Humanoid)(object)val)) { return false; } if (Time.time - _lastSitTime < 2f) { return false; } if (alt) { KartColorPickerUI.Open(this); return true; } if (Object.op_Implicit((Object)(object)_attachedPlayerLocal) && (Object)(object)val == (Object)(object)_attachedPlayerLocal) { SuperVikingKart.DebugLog("Kart Interact - Detaching player: " + val.GetPlayerName()); Detach(); _lastSitTime = Time.time; return true; } if (IsInUse()) { SuperVikingKart.DebugLog("Kart Interact - Already in use"); return false; } SuperVikingKart.DebugLog("Kart Interact - Attaching player: " + val.GetPlayerName()); Attach(val); _lastSitTime = Time.time; return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { if (Time.time - _lastSitTime < 2f) { return ""; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return ""; } if (!InUseDistance((Humanoid)(object)localPlayer)) { return Localization.instance.Localize("<color=grey>$piece_toofar</color>"); } if (!Object.op_Implicit((Object)(object)_attachedPlayerLocal) && IsInUse()) { return Localization.instance.Localize("<color=grey>In use</color>"); } return Localization.instance.Localize(Name + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] Change color"); } public string GetHoverName() { return Name; } private bool InUseDistance(Humanoid human) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)human) || !Object.op_Implicit((Object)(object)AttachPoint)) { return false; } return Vector3.Distance(((Component)human).transform.position, AttachPoint.position) < UseDistance; } } internal static class KartColorPickerUI { private static SuperVikingKartComponent _targetKart; public static void Open(SuperVikingKartComponent kart) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_006b: Expected O, but got Unknown if (!((Object)(object)kart == (Object)null)) { _targetKart = kart; GUIManager.Instance.CreateColorPicker(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), kart.GetCurrentColor(), "Kart Color", new ColorEvent(OnColorChanged), new ColorEvent(OnColorSelected), false); GUIManager.BlockInput(true); } } private static void OnColorChanged(Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_targetKart == (Object)null)) { _targetKart.ApplyColor(color); } } private static void OnColorSelected(Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_targetKart == (Object)null)) { Color currentColor = _targetKart.GetCurrentColor(); if (color == currentColor) { _targetKart.ApplyColor(currentColor); } else { _targetKart.SetColor(color); } _targetKart = null; GUIManager.BlockInput(false); } } } [HarmonyPatch(typeof(WearNTear), "Highlight")] internal class KartColorHighlightPatch { private static bool Prefix(WearNTear __instance) { return !Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInChildren<SuperVikingKartComponent>()); } } internal class KartRespawnComponent : MonoBehaviour, Hoverable { private float _timeRemaining; private TextMesh _text; private Camera _camera; public void Setup(float duration) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) _timeRemaining = duration; GameObject val = new GameObject("TimerText"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = Vector3.up * 2f; _text = val.AddComponent<TextMesh>(); _text.alignment = (TextAlignment)1; _text.anchor = (TextAnchor)4; _text.characterSize = 0.3f; _text.fontSize = 48; _text.color = Color.white; SphereCollider obj = ((Component)this).gameObject.AddComponent<SphereCollider>(); obj.radius = 1f; obj.center = Vector3.up * 2f; } private void Update() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) _timeRemaining -= Time.deltaTime; if (_timeRemaining <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } _text.text = Mathf.CeilToInt(_timeRemaining).ToString(); if (!Object.op_Implicit((Object)(object)_camera)) { _camera = Camera.main; } if (Object.op_Implicit((Object)(object)_camera)) { ((Component)_text).transform.rotation = ((Component)_camera).transform.rotation; } } public string GetHoverText() { return $"Kart respawning in {Mathf.CeilToInt(_timeRemaining)}s"; } public string GetHoverName() { return "Kart Respawn"; } } [HarmonyPatch(typeof(WearNTear), "Destroy")] internal class KartRespawnPatch { [CompilerGenerated] private sealed class <RespawnKart>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 position; public Quaternion rotation; public Color color; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RespawnKart>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds((float)SuperVikingKart.KartRespawnTimeConfig.Value); <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject prefab = PrefabManager.Instance.GetPrefab("SuperVikingKart"); if (!Object.op_Implicit((Object)(object)prefab)) { Logger.LogWarning((object)"KartRespawn - SuperVikingKart prefab not found"); return false; } SuperVikingKart.DebugLog($"KartRespawn - Spawning kart at {position}"); Object.Instantiate<GameObject>(prefab, position, rotation).GetComponentInChildren<SuperVikingKartComponent>().SetColor(color); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static bool IsBeingRemoved; private static void Prefix(WearNTear __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (IsBeingRemoved) { return; } SuperVikingKartComponent componentInChildren = ((Component)__instance).GetComponentInChildren<SuperVikingKartComponent>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsOwner()) { Vector3 position = ((Component)__instance).transform.position; float y = ((Component)__instance).transform.eulerAngles.y; Quaternion rotation = Quaternion.Euler(0f, y, 0f); Color currentColor = componentInChildren.GetCurrentColor(); SuperVikingKart.DebugLog($"KartRespawn - Kart destroyed at {position}, broadcasting and scheduling respawn"); component.InvokeRPC(ZNetView.Everybody, "SuperVikingKart_RPC_KartDestroyed", new object[2] { position, y }); ((MonoBehaviour)SuperVikingKart.Instance).StartCoroutine(RespawnKart(position, rotation, currentColor)); } } } [IteratorStateMachine(typeof(<RespawnKart>d__2))] private static IEnumerator RespawnKart(Vector3 position, Quaternion rotation, Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RespawnKart>d__2(0) { position = position, rotation = rotation, color = color }; } } [HarmonyPatch(typeof(WearNTear), "Remove")] internal class KartRemovePatch { private static void Prefix() { KartRespawnPatch.IsBeingRemoved = true; } private static void Postfix() { KartRespawnPatch.IsBeingRemoved = false; } } [HarmonyPatch(typeof(WearNTear), "Damage")] internal class KartSelfDamagePatch { private static bool Prefix(WearNTear __instance, HitData hit) { if (!Object.op_Implicit((Object)(object)__instance.m_nview) || __instance.m_nview.GetZDO() == null) { return true; } if (__instance.m_nview.GetZDO().m_prefab != SuperVikingKart.KartPrefabHash) { return true; } Character attacker = hit.GetAttacker(); if (!Object.op_Implicit((Object)(object)attacker)) { return true; } SuperVikingKartComponent componentInChildren = ((Component)__instance).GetComponentInChildren<SuperVikingKartComponent>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return true; } return (Object)(object)attacker != (Object)(object)componentInChildren.GetRider(); } } [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] internal class AttackThroughOwnKartPatch { private static void Prefix(Attack __instance, out List<Collider> __state) { __state = null; Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } foreach (SuperVikingKartComponent instance in SuperVikingKartComponent.Instances) { if ((Object)(object)instance.GetRiderLocal() != (Object)(object)val) { continue; } Vagon vagon = instance.GetVagon(); if (!Object.op_Implicit((Object)(object)vagon)) { continue; } __state = new List<Collider>(); Collider[] componentsInChildren = ((Component)vagon).GetComponentsInChildren<Collider>(); foreach (Collider val2 in componentsInChildren) { if (val2.enabled) { val2.enabled = false; __state.Add(val2); } } break; } } private static void Postfix(List<