Beispiel #1
0
        private static FieldInfo fi_NetPackagePlayerStats_entityId;                            // NetPackagePlayerStats      -> private int int_0;

        public static void Init()
        {
            try
            {
                fi_PowerTrigger_isTriggered       = ReflectionTools.GetField(typeof(PowerTrigger), "isTriggered");
                fi_PowerTrigger_isActive          = ReflectionTools.GetField(typeof(PowerTrigger), "isActive");
                fi_PowerTrigger_delayStartTime    = ReflectionTools.GetField(typeof(PowerTrigger), "delayStartTime");
                fi_PowerTrigger_powerTime         = ReflectionTools.GetField(typeof(PowerTrigger), "powerTime");
                fi_PowerConsumerToggle_isToggled  = ReflectionTools.GetField(typeof(PowerConsumerToggle), "isToggled");
                fi_PowerRangedTrap_isLocked       = ReflectionTools.GetField(typeof(PowerRangedTrap), "isLocked");
                fi_PowerItem_hasChangesLocal      = ReflectionTools.GetField(typeof(PowerItem), "hasChangesLocal");
                fi_TileEntityPowered_wireChildren = ReflectionTools.GetField(typeof(TileEntityPowered), typeof(List <Vector3i>));
                fi_TileEntityPowered_wireParent   = ReflectionTools.GetField(typeof(TileEntityPowered), typeof(Vector3i));
                fi_PowerManager_rootPowerItems    = ReflectionTools.GetField(typeof(PowerManager), typeof(List <PowerItem>));
                fi_TileEntity_readVersion         = ReflectionTools.GetField(typeof(TileEntity), "readVersion");
                fi_TileEntity_nextHeatMapEvent    = ReflectionTools.GetField(typeof(TileEntity), typeof(ulong));
                fi_TileEntityPowered_bool_1       = ReflectionTools.GetField(typeof(TileEntityPowered), typeof(bool), 2);                      // WARNING! Relying on member order here!
                fi_TileEntityPowered_bool_3       = ReflectionTools.GetField(typeof(TileEntityPowered), typeof(bool), 4);                      // WARNING! Relying on member order here!
                fi_SdtdConsole_commandObjects     = ReflectionTools.GetField(typeof(global::SdtdConsole), typeof(List <IConsoleCommand>));

                var t_StdtConsole_CommandObjectPair = ReflectionTools.GetNestedType(typeof(global::SdtdConsole), typeof(IConsoleCommand));                    // struct Struct13, last in source, has IConsoleCommand field
                fi_SdtdConsole_commandObjectPairs       = ReflectionTools.GetField(typeof(global::SdtdConsole), typeof(List <>).MakeGenericType(t_StdtConsole_CommandObjectPair));
                fi_SdtdConsole_commandObjectsReadOnly   = ReflectionTools.GetField(typeof(global::SdtdConsole), typeof(ReadOnlyCollection <IConsoleCommand>));
                ci_CommandObjectPair_Constructor        = ReflectionTools.GetConstructor(t_StdtConsole_CommandObjectPair, new[] { typeof(string), typeof(IConsoleCommand) });
                fi_CommandObjectPair_CommandField       = ReflectionTools.GetField(t_StdtConsole_CommandObjectPair, typeof(string));
                fi_CommandObjectPair_CommandObjectField = ReflectionTools.GetField(t_StdtConsole_CommandObjectPair, typeof(IConsoleCommand));

                mi_ChunkProviderGenerateWorld_generateTerrain          = ReflectionTools.GetMethod(typeof(ChunkProviderGenerateWorld), "generateTerrain");
                mi_ChunkProviderGenerateWorld_DecorateChunkOverlapping = ReflectionTools.GetMethod(typeof(ChunkProviderGenerateWorld), typeof(void), new [] { typeof(Chunk) }, 1); // WARNING! Relying on member order here!

                var t_ChunkAreaBiomeSpawnData_SpawnData = ReflectionTools.GetNestedType(typeof(ChunkAreaBiomeSpawnData), typeof(ulong));                                           // private struct LK, has public ulong PP;
                fi_ChunkAreaBiomeSpawnData_dict = ReflectionTools.GetField(typeof(ChunkAreaBiomeSpawnData), typeof(Dictionary <,>).MakeGenericType(typeof(string), t_ChunkAreaBiomeSpawnData_SpawnData));

                fi_EACServer_successDelegateField = ReflectionTools.GetField(typeof(EACServer), typeof(AuthenticationSuccessfulCallbackDelegate));
                fi_EACServer_kickDelegateField    = ReflectionTools.GetField(typeof(EACServer), typeof(KickPlayerDelegate));

                fi_EntityAlive_damageResponse = ReflectionTools.GetField(typeof(EntityAlive), typeof(DamageResponse));

                ev_MasterServerAnnouncer_add_ServerRegistered = ReflectionTools.GetAddMethod(typeof(MasterServerAnnouncer), typeof(void), new [] { typeof(Action) });

                fi_NetPackagePlayerStats_entityId = ReflectionTools.GetField(typeof(NetPackagePlayerStats), typeof(int), 0);                      // WARNING! Relying on member order here!

                Log.Out("Successfilly established reflection references.");
            }
            catch (Exception ex)
            {
                Log.Error("Error while establishing references to 7DTD's \"private parts\". Your game version might not be compatible with this Scripting Mod version." + Environment.NewLine + ex);
                throw;
            }
        }