public static bool Prefix(ChunkWorld __instance, int[] msg, ref GameObject[,] ___gridSpecialObj)
 {
     if (TileRegistry.GetSingleton().HasEntry(msg[2]))
     {
         TileInfo tile = TileRegistry.GetSingleton().GetEntry(msg[2]);
         int      num  = msg[0];
         int      num2 = msg[1];
         int      num3 = (num + 62) / 4;
         int      num4 = (num2 + 62) / 4;
         int      num5 = msg[2];
         __instance.gridSpecial[num3, num4] = num5;
         if (tile.Type != TileType.INTERACTIVE)
         {
             ___gridSpecialObj[num3, num4] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("prop/" + num5), new Vector3(num, num2, 0.9f), Quaternion.identity);
         }
         else
         {
             ___gridSpecialObj[num3, num4] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("npc/npc" + num5), new Vector3(num, num2, 0.9f), Quaternion.identity);
         }
         ___gridSpecialObj[num3, num4].transform.parent = __instance.transform;
         MultiplayerSupport.Invoke(__instance, new object[] { });
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            CodeInstruction[]      codes    = instructions.ToArray();
            List <CodeInstruction> newCodes = new List <CodeInstruction>();

            for (int i = 0; i < 11; i++)
            {
                newCodes.Add(codes[i]);
            }
            for (int i = 11; i < codes.Length; i++)
            {
                newCodes.Add(codes[i]);
                if (codes[i - 11] != null && codes[i - 11].opcode == OpCodes.Ldloc_S &&
                    codes[i - 10] != null && codes[i - 10].opcode == OpCodes.Ldc_I4_S &&
                    codes[i - 9] != null && codes[i - 9].opcode == OpCodes.Bge &&
                    codes[i - 8] != null && codes[i - 8].opcode == OpCodes.Ldloc_S &&
                    codes[i - 7] != null && codes[i - 7].opcode == OpCodes.Ldc_I4_0 &&
                    codes[i - 6] != null && codes[i - 6].opcode == OpCodes.Blt &&
                    codes[i - 5] != null && codes[i - 5].opcode == OpCodes.Ldloc_S &&
                    codes[i - 4] != null && codes[i - 4].opcode == OpCodes.Ldc_I4_S &&
                    codes[i - 3] != null && codes[i - 3].opcode == OpCodes.Bge &&
                    codes[i - 2] != null && codes[i - 2].opcode == OpCodes.Ldloc_S &&
                    codes[i - 1] != null && codes[i - 1].opcode == OpCodes.Ldc_I4_0 &&
                    codes[i] != null && codes[i].opcode == OpCodes.Blt)
                {
                    if (codes.Length > i + 1 && codes[i + 1].opcode == OpCodes.Ldsfld)
                    {
                        newCodes.Add(new CodeInstruction(OpCodes.Ldsfld, codes[i + 1].operand));
                        newCodes.Add(new CodeInstruction(OpCodes.Ldc_I4, TileRegistry.GetSingleton().GetIDStart()));
                        newCodes.Add(new CodeInstruction(OpCodes.Bge, codes[i].operand));
                    }
                }
            }
            return(newCodes);
        }
Beispiel #3
0
 public static bool Prefix(ChunkWorld __instance, ref int[] gg)
 {
     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
     {
         __instance.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, gg));
         return(false);
     }
     for (int i = 0; i < gg.Length; i++)
     {
         GadgetNetwork.ConvertIDToLocal(TileRegistry.GetSingleton(), ref gg[i]);
     }
     return(true);
 }
 public static bool Prefix(PlayerScript __instance, int id, ref IEnumerator __result)
 {
     if (TileRegistry.GetSingleton().HasEntry(id))
     {
         TileInfo tile = TileRegistry.GetSingleton().GetEntry(id);
         IEnumerable <IEnumerator> interactions = tile.Interact();
         if (interactions != null)
         {
             __result = InteractAll(__instance, interactions);
             return(false);
         }
     }
     return(true);
 }
 public static bool Prefix(PlayerTrigger __instance, int id, ref IEnumerator __result)
 {
     if (TileRegistry.GetSingleton().HasEntry(id))
     {
         TileInfo    tile   = TileRegistry.GetSingleton().GetEntry(id);
         IEnumerator result = tile.Interact();
         if (result != null)
         {
             __result = result;
             return(false);
         }
     }
     return(true);
 }
Beispiel #6
0
 public static bool Prefix(SpawnerScript __instance, ref int[] s)
 {
     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
     {
         __instance.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, s));
         return(false);
     }
     GadgetNetwork.ConvertIDToLocal(null /* WorldRegistry */, ref s[0]);
     for (int i = 1; i < s.Length; i++)
     {
         GadgetNetwork.ConvertIDToLocal(TileRegistry.GetSingleton(), ref s[i]);
     }
     return(true);
 }
Beispiel #7
0
 public static bool Prefix(ChunkWorld __instance, ref GameObject[,] ___gridSpecialObj)
 {
     for (int i = 0; i < 64; i++)
     {
         for (int j = 0; j < 64; j++)
         {
             if (__instance.gridSpecial[i, j] > 0)
             {
                 if (___gridSpecialObj[i, j] == null)
                 {
                     if (TileRegistry.GetSingleton().HasEntry(__instance.gridSpecial[i, j]))
                     {
                         TileInfo tile = TileRegistry.GetSingleton().GetEntry(__instance.gridSpecial[i, j]);
                         if (tile.Type == TileType.INTERACTIVE)
                         {
                             ___gridSpecialObj[i, j] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("npc/npc" + __instance.gridSpecial[i, j]), new Vector3((float)(i * 4 - 62), (float)(j * 4 - 62), 0.9f), Quaternion.identity);
                         }
                         else
                         {
                             ___gridSpecialObj[i, j] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("prop/" + __instance.gridSpecial[i, j]), new Vector3((float)(i * 4 - 62), (float)(j * 4 - 62), 0.9f), Quaternion.identity);
                         }
                     }
                     else
                     {
                         if (__instance.gridSpecial[i, j] < 2400)
                         {
                             ___gridSpecialObj[i, j] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("npc/npc" + __instance.gridSpecial[i, j]), new Vector3((float)(i * 4 - 62), (float)(j * 4 - 62), 0.9f), Quaternion.identity);
                         }
                         else
                         {
                             ___gridSpecialObj[i, j] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("prop/" + __instance.gridSpecial[i, j]), new Vector3((float)(i * 4 - 62), (float)(j * 4 - 62), 0.9f), Quaternion.identity);
                         }
                         if (__instance.gridSpecial[i, j] != 2106 && __instance.gridSpecial[i, j] != 2107 && __instance.gridSpecial[i, j] != 2105)
                         {
                             ___gridSpecialObj[i, j].transform.parent = __instance.transform;
                         }
                     }
                 }
             }
             else if (___gridSpecialObj[i, j])
             {
                 UnityEngine.Object.Destroy(___gridSpecialObj[i, j]);
             }
         }
     }
     return(false);
 }
Beispiel #8
0
 private static void InitializeRegistries()
 {
     Log("Initializing Registries");
     GameRegistry.RegisterRegistry(ItemRegistry.GetSingleton());
     GameRegistry.RegisterRegistry(ChipRegistry.GetSingleton());
     GameRegistry.RegisterRegistry(TileRegistry.GetSingleton());
     GameRegistry.RegisterRegistry(EntityRegistry.GetSingleton());
     foreach (GadgetModInfo mod in GadgetMods.ListAllModInfos())
     {
         if (mod.Mod.Enabled)
         {
             foreach (Registry registry in mod.Mod.CreateRegistries())
             {
                 GameRegistry.RegisterRegistry(registry);
             }
         }
     }
     Log("Finished Initializing Registries");
 }
Beispiel #9
0
 public static bool Prefix(ChunkWorld __instance, byte brick, Vector3 corner, Vector3 up, Vector3 right, bool reversed, List <Vector3> verts, List <Vector2> uvs, List <int> tris, int id, int face)
 {
     if (TileRegistry.GetSingleton().HasEntry(id))
     {
         TileInfo tile  = TileRegistry.GetSingleton().GetEntry(id);
         int      count = verts.Count;
         if (tile.Type == TileType.SOLID || tile.Type == TileType.WALL)
         {
             verts.Add(corner);
             verts.Add(corner + up);
             verts.Add(corner + up + right);
             verts.Add(corner + right);
         }
         else
         {
             if (face == 4)
             {
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f));
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f) + up);
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f) + up + right);
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f) + right);
             }
             else if (face == 0 || face == 1)
             {
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f));
                 verts.Add(corner + up + new Vector3(0f, 0f, 0.5f));
                 verts.Add(corner + up + right);
                 verts.Add(corner + right);
             }
             else if (face != 5)
             {
                 verts.Add(corner + new Vector3(0f, 0f, 0.5f));
                 verts.Add(corner + up);
                 verts.Add(corner + up + right);
                 verts.Add(corner + right + new Vector3(0f, 0f, 0.5f));
             }
             else
             {
                 verts.Add(corner);
                 verts.Add(corner + up);
                 verts.Add(corner + up + right);
                 verts.Add(corner + right);
             }
         }
         uvs.Add(new Vector2(tile.Sprite.coords.x, tile.Sprite.coords.y));
         uvs.Add(new Vector2(tile.Sprite.coords.x, tile.Sprite.coords.y + 1));
         uvs.Add(new Vector2(tile.Sprite.coords.x + 1, tile.Sprite.coords.y + 1));
         uvs.Add(new Vector2(tile.Sprite.coords.x + 1, tile.Sprite.coords.y));
         if (reversed)
         {
             tris.Add(count);
             tris.Add(count + 1);
             tris.Add(count + 2);
             tris.Add(count + 2);
             tris.Add(count + 3);
             tris.Add(count);
         }
         else
         {
             tris.Add(count + 1);
             tris.Add(count);
             tris.Add(count + 2);
             tris.Add(count + 3);
             tris.Add(count + 2);
             tris.Add(count);
         }
         return(false);
     }
     return(true);
 }
Beispiel #10
0
        public static bool Prefix(NetworkView __instance, string name, RPCMode mode, ref object[] args)
        {
            if (Assembly.GetCallingAssembly().Equals(typeof(GameScript).Assembly))
            {
                switch (name)
                {
                case "Set":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref args[0]);
                        }
                    }
                    else if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[0]);
                        }
                        else if (args[0] is Package2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref (args[0] as Package2).id);
                        }
                    }
                    break;

                case "UA":
                    if (args.Length == 3)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 8)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[1]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[2]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[3]);
                            GadgetNetwork.ConvertIDToHost(null /* RaceRegistry */, ref (args[0] as int[])[4]);
                            GadgetNetwork.ConvertIDToHost(null /* UniformRegistry */, ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(null /* AugmentRegistry */, ref (args[0] as int[])[7]);
                        }
                    }
                    else if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 3)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[1]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[2]);
                        }
                    }
                    break;

                case "ShootProjectile":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "CreateWorld":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length > 1)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref (args[0] as int[])[0]);
                            for (int i = 1; i < (args[0] as int[]).Length; i++)
                            {
                                GadgetNetwork.ConvertIDToHost(TileRegistry.GetSingleton(), ref (args[0] as int[])[i]);
                            }
                        }
                    }
                    break;

                case "CreateTown":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref (args[0] as int[])[0]);
                        }
                    }
                    break;

                case "SpawnProjectile":
                    if (args.Length == 4)
                    {
                        if (args[1] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[1]);
                        }
                    }
                    break;

                case "SetNetworked":
                    if (args.Length == 3)
                    {
                        if (args[1] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[1]);
                        }
                    }
                    break;

                case "SetName":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "Staff":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "ShootSpecial":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "ShootProjectile2":
                    if (args.Length == 4)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "NetworkedProjectile":
                    if (args.Length == 4)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton() /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "Init":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length >= 11)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[5]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[7]);
                        }
                    }
                    break;

                case "Chip":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ChipRegistry.GetSingleton(), ref args[0]);
                        }
                    }
                    break;

                case "SpawnItem":
                    if (args.Length == 2)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length >= 11)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[5]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.GetSingleton(), ref (args[0] as int[])[7]);
                        }
                    }
                    break;

                case "ChangePortal":
                    if (args.Length == 2)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "ChangePortal2":
                    if (args.Length == 2)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "RefreshWall":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[])
                        {
                            for (int i = 0; i < (args[0] as int[]).Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.GetSingleton(), ref (args[0] as int[])[i]);
                            }
                        }
                    }
                    break;

                case "RefreshShip":
                    if (args.Length == 2)
                    {
                        if (args[0] is int[] && args[1] is int[])
                        {
                            for (int i = 0; i < (args[0] as int[]).Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.GetSingleton(), ref (args[0] as int[])[i]);
                            }
                            for (int i = 0; i < (args[1] as int[]).Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.GetSingleton(), ref (args[1] as int[])[i]);
                            }
                        }
                    }
                    break;

                case "SetMaterial":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(null /* WorldRegistry */, ref args[0]);
                        }
                    }
                    break;
                }
            }
            return(true);
        }