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 GeneticArtifact v4.5.5
plugins/GeneticsArtifact.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GeneticsArtifact.CheatManager; using GeneticsArtifact.SgdEngine; using GeneticsArtifact.SgdEngine.Actuators; using GeneticsArtifact.SgdEngine.Decision; using GeneticsArtifact.Telemetry; using HG.Reflection; using On.RoR2; using On.RoR2.UI.MainMenu; using R2API; using R2API.ScriptableObjects; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GeneticsArtifact")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5e6d6d576df470ec315cbd16c889d2b57a01e6f0")] [assembly: AssemblyProduct("GeneticsArtifact")] [assembly: AssemblyTitle("GeneticsArtifact")] [assembly: AssemblyVersion("1.0.0.0")] namespace GeneticsArtifact { public class ArtifactOfGenetics { public static ArtifactDef artifactDef; public static ArtifactCode artifactCode; public static ArtifactCompoundDef geneArtifactCompoundDef; internal static void Init() { //IL_00e8: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) LanguageAPI.Add("GENETIC_ARTIFACT_NAME_TOKEN", "Artifact of Genetics"); LanguageAPI.Add("GENETIC_ARTIFACT_DESCRIPTION_TOKEN", "Monsters will spawn with adjusted stats. Adjustments are determined by a genetic algorithm."); artifactDef = ScriptableObject.CreateInstance<ArtifactDef>(); artifactDef.nameToken = "GENETIC_ARTIFACT_NAME_TOKEN"; artifactDef.descriptionToken = "GENETIC_ARTIFACT_DESCRIPTION_TOKEN"; artifactDef.smallIconSelectedSprite = GeneticsArtifactPlugin.geneticAssetBundle.LoadAsset<Sprite>("Assets/Genetics/Selected.png"); artifactDef.smallIconDeselectedSprite = GeneticsArtifactPlugin.geneticAssetBundle.LoadAsset<Sprite>("Assets/Genetics/Unselected.png"); artifactDef.pickupModelPrefab = GeneticsArtifactPlugin.geneticAssetBundle.LoadAsset<GameObject>("Assets/Genetics/PickupGene.prefab"); ContentAddition.AddArtifactDef(artifactDef); geneArtifactCompoundDef = ScriptableObject.CreateInstance<ArtifactCompoundDef>(); geneArtifactCompoundDef.modelPrefab = GeneticsArtifactPlugin.geneticAssetBundle.LoadAsset<GameObject>("Assets/Genetics/CompoundGene.prefab"); geneArtifactCompoundDef.value = 15; ArtifactCodeAPI.AddCompound(geneArtifactCompoundDef); artifactCode = ScriptableObject.CreateInstance<ArtifactCode>(); artifactCode.topRow = new Vector3Int(3, 5, 3); artifactCode.middleRow = new Vector3Int(1, geneArtifactCompoundDef.value, 1); artifactCode.bottomRow = new Vector3Int(3, 5, 3); ArtifactCodeAPI.AddCode(artifactDef, artifactCode); } } public class ConfigManager { private static ConfigFile _configFile; public static ConfigEntry<int> timeLimit; public static ConfigEntry<int> deathLimit; public static ConfigEntry<int> governorType; public static ConfigEntry<float> geneVarianceLimit; public static ConfigEntry<float> geneCap; public static ConfigEntry<float> geneFloor; public static ConfigEntry<float> geneProductLimit; public static ConfigEntry<bool> maintainIfDisabled; public static ConfigEntry<bool> enableGeneLimitOverrides; public static ConfigEntry<string> geneLimitOverrides; public static ConfigEntry<float> sgdNormTargetTimeToDieSeconds; public static ConfigEntry<float> sgdNormTargetTtkSeconds; public static ConfigEntry<float> sgdNormHitRateScalePerSecond; public static ConfigEntry<float> sgdHpFloor; public static ConfigEntry<float> sgdHpCap; public static ConfigEntry<float> sgdMsFloor; public static ConfigEntry<float> sgdMsCap; public static ConfigEntry<float> sgdAsFloor; public static ConfigEntry<float> sgdAsCap; public static ConfigEntry<float> sgdDmgFloor; public static ConfigEntry<float> sgdDmgCap; public static ConfigEntry<bool> telemetryEnabled; public static ConfigEntry<string> telemetryAnonymousUserId; public static ConfigEntry<string> telemetryParticipantId; public static ConfigEntry<string> telemetryExperimentId; public static ConfigEntry<string> telemetryConditionOrder; public static ConfigEntry<int> telemetryRunAttemptIndex; public static ConfigEntry<string> telemetryConfiguredRunSeed; public static ConfigEntry<float> telemetrySampleIntervalSeconds; public static ConfigEntry<float> telemetryFlushIntervalSeconds; public static ConfigEntry<int> telemetryMaxQueueSize; public static ConfigEntry<float> telemetryJumpThreshold; public static ConfigEntry<float> telemetryVirtualGapEpsilon; public static ConfigEntry<float> telemetryStableErrorEpsilon; public static ConfigEntry<float> telemetryDegradationThreshold; public static ConfigEntry<float> telemetryRecoveryThreshold; public static ConfigEntry<float> telemetryMinimumSessionSeconds; public static ConfigEntry<bool> researchAutoRotateDdaAlgorithms; public static ConfigEntry<string> researchLastRunDdaAlgorithm; public static ConfigEntry<bool> researchAutoRotateRunSeeds; public static ConfigEntry<string> researchRunSeedCycle; public static ConfigEntry<int> researchCurrentRunSeedIndex; public static ConfigEntry<string> researchCurrentRunSeed; public static ConfigEntry<bool> diagnosticsEnableGeneTokenCalcHooks; public static ConfigEntry<bool> diagnosticsEnableGeneticEngineHooks; public static ConfigEntry<bool> diagnosticsEnableSgdHooks; public static ConfigEntry<bool> diagnosticsEnableSgdActuatorsHooks; public static ConfigEntry<bool> diagnosticsEnableTelemetryHooks; public static ConfigEntry<bool> diagnosticsEnableRunModeRotatorHooks; public static void Init(ConfigFile configFile) { //IL_0011: 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) //IL_0032: Expected O, but got Unknown //IL_0032: Expected O, but got Unknown //IL_0042: 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: Expected O, but got Unknown //IL_0068: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_009c: Expected O, but got Unknown //IL_00ac: 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) //IL_00d5: Expected O, but got Unknown //IL_00d5: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0112: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_014f: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_018c: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01c9: Expected O, but got Unknown //IL_01d9: 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_0202: Expected O, but got Unknown //IL_0202: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0231: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_026e: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_02ab: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Expected O, but got Unknown //IL_02e8: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown //IL_0325: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_0362: Expected O, but got Unknown //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_039f: Expected O, but got Unknown //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Expected O, but got Unknown //IL_03dc: Expected O, but got Unknown //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_0419: Expected O, but got Unknown //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Expected O, but got Unknown //IL_0456: Expected O, but got Unknown //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Expected O, but got Unknown //IL_0493: Expected O, but got Unknown //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Expected O, but got Unknown //IL_04d0: Expected O, but got Unknown //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Expected O, but got Unknown //IL_04fb: Expected O, but got Unknown //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Expected O, but got Unknown //IL_052a: Expected O, but got Unknown //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Expected O, but got Unknown //IL_0596: Expected O, but got Unknown //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Expected O, but got Unknown //IL_05c5: Expected O, but got Unknown //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Expected O, but got Unknown //IL_05f4: Expected O, but got Unknown //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Expected O, but got Unknown //IL_0629: Expected O, but got Unknown //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Expected O, but got Unknown //IL_0658: Expected O, but got Unknown //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0695: Expected O, but got Unknown //IL_0695: Expected O, but got Unknown //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Expected O, but got Unknown //IL_06d2: Expected O, but got Unknown //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Expected O, but got Unknown //IL_070c: Expected O, but got Unknown //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Expected O, but got Unknown //IL_0749: Expected O, but got Unknown //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Expected O, but got Unknown //IL_0786: Expected O, but got Unknown //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Expected O, but got Unknown //IL_07c3: Expected O, but got Unknown //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Expected O, but got Unknown //IL_0800: Expected O, but got Unknown //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Expected O, but got Unknown //IL_083d: Expected O, but got Unknown //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Expected O, but got Unknown //IL_087a: Expected O, but got Unknown //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a5: Expected O, but got Unknown //IL_08a5: Expected O, but got Unknown //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Unknown result type (might be due to invalid IL or missing references) //IL_08fe: Expected O, but got Unknown //IL_08fe: Expected O, but got Unknown //IL_090e: Unknown result type (might be due to invalid IL or missing references) //IL_091f: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Expected O, but got Unknown //IL_0929: Expected O, but got Unknown //IL_0939: Unknown result type (might be due to invalid IL or missing references) //IL_094e: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Expected O, but got Unknown //IL_0958: Expected O, but got Unknown //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_0983: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Expected O, but got Unknown //IL_098d: Expected O, but got Unknown //IL_099d: Unknown result type (might be due to invalid IL or missing references) //IL_09b2: Unknown result type (might be due to invalid IL or missing references) //IL_09bc: Expected O, but got Unknown //IL_09bc: Expected O, but got Unknown //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e7: Expected O, but got Unknown //IL_09e7: Expected O, but got Unknown //IL_09f7: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a12: Expected O, but got Unknown //IL_0a12: Expected O, but got Unknown //IL_0a22: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a3d: Expected O, but got Unknown //IL_0a3d: Expected O, but got Unknown //IL_0a4d: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_0a68: Expected O, but got Unknown //IL_0a68: Expected O, but got Unknown //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a89: Unknown result type (might be due to invalid IL or missing references) //IL_0a93: Expected O, but got Unknown //IL_0a93: Expected O, but got Unknown //IL_0aa3: Unknown result type (might be due to invalid IL or missing references) //IL_0ab4: Unknown result type (might be due to invalid IL or missing references) //IL_0abe: Expected O, but got Unknown //IL_0abe: Expected O, but got Unknown _configFile = configFile; governorType = configFile.Bind<int>(new ConfigDefinition("GeneEngineDriver Variables", "Learning Governor Type"), 0, new ConfigDescription("How the algorithm decides when to learn: 0 - Default, 1 - Time Only, 2 - Death Count Only", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>())); timeLimit = configFile.Bind<int>(new ConfigDefinition("GeneEngineDriver Variables", "Time Limit"), 60, new ConfigDescription("How many seconds between learnings:", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 300), Array.Empty<object>())); deathLimit = configFile.Bind<int>(new ConfigDefinition("GeneEngineDriver Variables", "Death Limit"), 40, new ConfigDescription("How many monster deaths between learnings:", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>())); maintainIfDisabled = configFile.Bind<bool>(new ConfigDefinition("GeneEngineDriver Variables", "Keep Mutations While Disabled"), false, new ConfigDescription("Should the stat mods still be applied if the artifact is disabled mid-run:", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); geneCap = configFile.Bind<float>(new ConfigDefinition("Mutation Variables", "Gene Value Cap"), 10f, new ConfigDescription("Maximum multiplier for any stat:", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); geneFloor = configFile.Bind<float>(new ConfigDefinition("Mutation Variables", "Gene Value Floor"), 0.01f, new ConfigDescription("Minimum multiplier for any stat:", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); geneProductLimit = configFile.Bind<float>(new ConfigDefinition("Mutation Variables", "Gene Product Cap"), 1.5f, new ConfigDescription("Maximum product of all stat multipliers:", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); geneVarianceLimit = configFile.Bind<float>(new ConfigDefinition("Mutation Variables", "Gene Variation Limit"), 0.1f, new ConfigDescription("How much a monster can differ from it`s master as a percent: 0.1 is 10% (Bulwark will be 5x this)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); enableGeneLimitOverrides = configFile.Bind<bool>(new ConfigDefinition("Mutation Override Variables", "Enable Mutation Overrides"), false, new ConfigDescription("Should the mutation overrides be applied, use with caution", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); geneLimitOverrides = configFile.Bind<string>(new ConfigDefinition("Mutation Override Variables", "Gene Limit Overrides"), "MoveSpeed,0.5,2|InvalidName,0.8,NaN", new ConfigDescription("Format is as follows: GeneName1,Floor1,Cap1|GeneName2,Floor2,Cap2 where GeneName is in (MaxHealth,MoveSpeed,AttackSpeed,AttackDamage) and Floor and Cap are parseable numerics", (AcceptableValueBase)null, Array.Empty<object>())); sgdNormTargetTimeToDieSeconds = configFile.Bind<float>(new ConfigDefinition("SGD Sensor Normalization", "Target Time To Die (seconds)"), 10f, new ConfigDescription("Target survival horizon used for normalizing incoming DPS against V_p(defense). Higher => less sensitive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); sgdNormTargetTtkSeconds = configFile.Bind<float>(new ConfigDefinition("SGD Sensor Normalization", "Target Time To Kill (seconds)"), 8f, new ConfigDescription("Target TTK used for normalizing AvgTTK. Higher => less sensitive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); sgdNormHitRateScalePerSecond = configFile.Bind<float>(new ConfigDefinition("SGD Sensor Normalization", "Hit Rate Scale (per second)"), 1.5f, new ConfigDescription("Scale for normalizing hit rate (hits/sec) into [0..1]. Higher => less sensitive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); sgdHpFloor = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "HP Floor"), 0.01f, new ConfigDescription("Minimum SGD multiplier for MaxHealth axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); sgdHpCap = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "HP Cap"), 10f, new ConfigDescription("Maximum SGD multiplier for MaxHealth axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); sgdMsFloor = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "MoveSpeed Floor"), 0.01f, new ConfigDescription("Minimum SGD multiplier for MoveSpeed axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); sgdMsCap = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "MoveSpeed Cap"), 10f, new ConfigDescription("Maximum SGD multiplier for MoveSpeed axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); sgdAsFloor = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "AttackSpeed Floor"), 0.01f, new ConfigDescription("Minimum SGD multiplier for AttackSpeed axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); sgdAsCap = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "AttackSpeed Cap"), 10f, new ConfigDescription("Maximum SGD multiplier for AttackSpeed axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); sgdDmgFloor = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "AttackDamage Floor"), 0.01f, new ConfigDescription("Minimum SGD multiplier for AttackDamage axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); sgdDmgCap = configFile.Bind<float>(new ConfigDefinition("SGD Axis Limits", "AttackDamage Cap"), 10f, new ConfigDescription("Maximum SGD multiplier for AttackDamage axis.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); telemetryEnabled = configFile.Bind<bool>(new ConfigDefinition("Research Telemetry", "Telemetry Enabled"), true, new ConfigDescription("Send anonymous DDA research telemetry to the configured PostHog project. Disable to opt out.", (AcceptableValueBase)null, Array.Empty<object>())); telemetryAnonymousUserId = configFile.Bind<string>(new ConfigDefinition("Research Telemetry", "Anonymous User Id"), "", new ConfigDescription("Anonymous UUID for grouping runs from the same installation. Generated automatically if empty.", (AcceptableValueBase)null, Array.Empty<object>())); if (string.IsNullOrWhiteSpace(telemetryAnonymousUserId.Value)) { telemetryAnonymousUserId.Value = "anon-" + Guid.NewGuid().ToString("N"); configFile.Save(); } telemetryParticipantId = configFile.Bind<string>(new ConfigDefinition("Research Telemetry", "Participant Id"), "", new ConfigDescription("Explicit participant code for thesis experiments. Leave empty to reuse Anonymous User Id.", (AcceptableValueBase)null, Array.Empty<object>())); telemetryExperimentId = configFile.Bind<string>(new ConfigDefinition("Research Telemetry", "Experiment Id"), "thesis_v1", new ConfigDescription("Experiment label used to segment telemetry in a single PostHog project.", (AcceptableValueBase)null, Array.Empty<object>())); telemetryConditionOrder = configFile.Bind<string>(new ConfigDefinition("Research Telemetry", "Condition Order"), "FLS,GA,SGD", new ConfigDescription("Planned condition order for the current participant, e.g. FLS,GA,SGD.", (AcceptableValueBase)null, Array.Empty<object>())); telemetryRunAttemptIndex = configFile.Bind<int>(new ConfigDefinition("Research Telemetry", "Run Attempt Index"), 1, new ConfigDescription("Explicit attempt number within the current participant/condition.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>())); telemetryConfiguredRunSeed = configFile.Bind<string>(new ConfigDefinition("Research Telemetry", "Configured Run Seed"), "", new ConfigDescription("Optional planned run seed or scenario label. Runtime seed is logged separately when available.", (AcceptableValueBase)null, Array.Empty<object>())); telemetrySampleIntervalSeconds = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Sample Interval Seconds"), 10f, new ConfigDescription("How often to sample runtime DDA telemetry.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>())); telemetryFlushIntervalSeconds = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Flush Interval Seconds"), 20f, new ConfigDescription("How often to flush queued telemetry events to PostHog.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f), Array.Empty<object>())); telemetryMaxQueueSize = configFile.Bind<int>(new ConfigDefinition("Research Telemetry", "Max Queue Size"), 512, new ConfigDescription("Maximum in-memory telemetry events kept before oldest events are dropped.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(32, 5000), Array.Empty<object>())); telemetryJumpThreshold = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Jump Threshold"), 0.1f, new ConfigDescription("Absolute multiplier delta treated as a sharp difficulty jump.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); telemetryVirtualGapEpsilon = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Virtual Gap Epsilon"), 0.5f, new ConfigDescription("Acceptance threshold epsilon_v for |V_c - V_p| in H3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); telemetryStableErrorEpsilon = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Stable Error Epsilon"), 0.1f, new ConfigDescription("Stable corridor epsilon_stable for mean alignment error in H4.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); telemetryDegradationThreshold = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Degradation Threshold"), 0.7f, new ConfigDescription("Stress signal threshold that starts a degradation episode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); telemetryRecoveryThreshold = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Recovery Threshold"), 0.35f, new ConfigDescription("Stress signal threshold that ends a degradation episode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.9f), Array.Empty<object>())); telemetryMinimumSessionSeconds = configFile.Bind<float>(new ConfigDefinition("Research Telemetry", "Minimum Session Seconds"), 300f, new ConfigDescription("Sessions shorter than this are marked as quality-excluded in telemetry.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 7200f), Array.Empty<object>())); researchAutoRotateDdaAlgorithms = configFile.Bind<bool>(new ConfigDefinition("Research DDA Rotation", "Auto Rotate Algorithms"), true, new ConfigDescription("Automatically rotate hidden DDA mode on each new run: FLS -> GA -> SGD -> FLS.", (AcceptableValueBase)null, Array.Empty<object>())); researchLastRunDdaAlgorithm = configFile.Bind<string>(new ConfigDefinition("Research DDA Rotation", "Last Run Algorithm"), "None", new ConfigDescription("Last hidden DDA algorithm launched by the research rotator. Do not edit during experiments unless you want to reset the sequence.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "None", "FLS", "GA", "SGD" }), Array.Empty<object>())); researchAutoRotateRunSeeds = configFile.Bind<bool>(new ConfigDefinition("Research DDA Rotation", "Auto Rotate Run Seeds"), true, new ConfigDescription("When enabled, keeps one configured run seed for a full FLS -> GA -> SGD cycle, then advances to the next seed.", (AcceptableValueBase)null, Array.Empty<object>())); researchRunSeedCycle = configFile.Bind<string>(new ConfigDefinition("Research DDA Rotation", "Run Seed Cycle"), "8459684015804115075,8821573197706646788,2559340200192868678,97399012779323199,1444060760769064427", new ConfigDescription("Comma-separated list of planned run seeds for thesis experiments. Example: 12345,67890,13579. Empty disables forced seed assignment.", (AcceptableValueBase)null, Array.Empty<object>())); researchCurrentRunSeedIndex = configFile.Bind<int>(new ConfigDefinition("Research DDA Rotation", "Current Run Seed Index"), 0, new ConfigDescription("Index in Run Seed Cycle currently used by the hidden research rotator. Do not edit during experiments unless you want to reset the sequence.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000000), Array.Empty<object>())); researchCurrentRunSeed = configFile.Bind<string>(new ConfigDefinition("Research DDA Rotation", "Current Run Seed"), "", new ConfigDescription("Current planned run seed used for the active FLS -> GA -> SGD cycle. Stored to survive client restarts.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableGeneTokenCalcHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable GeneTokenCalc Hooks"), false, new ConfigDescription("Enable RecalculateStats hooks (GeneTokenCalc). Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableGeneticEngineHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable GeneticEngine Hooks"), false, new ConfigDescription("Enable GeneticEngine hooks (GeneEngineDriver). Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableSgdHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable SGD Hooks"), true, new ConfigDescription("Enable SGD runtime + sensors hooks. Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableSgdActuatorsHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable SGD Actuators Hooks"), false, new ConfigDescription("Enable SGD actuators hooks. Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableTelemetryHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable Telemetry Hooks"), true, new ConfigDescription("Enable telemetry hooks (dda_sample/session_end/etc). Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); diagnosticsEnableRunModeRotatorHooks = configFile.Bind<bool>(new ConfigDefinition("Diagnostics", "Enable Research Rotator Hooks"), true, new ConfigDescription("Enable research run mode rotator hooks. Keep disabled while diagnosing repeat-run startup errors.", (AcceptableValueBase)null, Array.Empty<object>())); } public static void Save() { ConfigFile configFile = _configFile; if (configFile != null) { configFile.Save(); } } } public enum GovernorType { Default, TimeOnly, DeathsOnly } public class RiskOfOptionsCompat { public static void Init() { //IL_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //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_0052: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ba: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_018e: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_0198: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Expected O, but got Unknown //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: 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_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Expected O, but got Unknown ModSettingsManager.SetModIcon(ArtifactOfGenetics.artifactDef.smallIconSelectedSprite); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ConfigManager.governorType, new IntSliderConfig { min = 0, max = 2 })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ConfigManager.timeLimit, new IntSliderConfig { min = 5, max = 300 })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ConfigManager.deathLimit, new IntSliderConfig { min = 10, max = 100 })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigManager.maintainIfDisabled)); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.geneCap, new SliderConfig { min = 1f, max = 50f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.geneFloor, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.geneProductLimit, new SliderConfig { min = 1f, max = 10f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.geneVarianceLimit, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:#0.##%}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdHpFloor, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdHpCap, new SliderConfig { min = 1f, max = 50f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdMsFloor, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdMsCap, new SliderConfig { min = 1f, max = 50f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdAsFloor, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdAsCap, new SliderConfig { min = 1f, max = 50f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdDmgFloor, new SliderConfig { min = 0.01f, max = 1f, formatString = "{0:0.##}x" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(ConfigManager.sgdDmgCap, new SliderConfig { min = 1f, max = 50f, formatString = "{0:#0.##}x" })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigManager.enableGeneLimitOverrides)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ConfigManager.geneLimitOverrides)); } } public class GeneEngineDriver : NetworkBehaviour { public static GeneEngineDriver instance; public static List<MasterGeneBehaviour> masterGenes; public static List<MonsterGeneBehaviour> livingGenes; public static List<MonsterGeneBehaviour> deadGenes; public static float timeSinceLastLearning; public static Dictionary<GeneStat, (float, float)> geneLimitOverrides; public event EventHandler GEDPostLearningEvent; public static void RegisterHooks() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown Run.Start += new hook_Start(Run_Start); CharacterBody.Start += new hook_Start(CharacterBody_Start); HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage); } private static void Run_Start(orig_Start orig, Run self) { orig.Invoke(self); if (NetworkServer.active && DdaAlgorithmState.ShouldRunGeneticEngine()) { ((Component)self).gameObject.AddComponent<GeneEngineDriver>(); } } private static void CharacterBody_Start(orig_Start orig, CharacterBody self) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!NetworkServer.active || !DdaAlgorithmState.ShouldRunGeneticEngine()) { return; } if ((Object)(object)instance == (Object)null) { ((Component)Run.instance).gameObject.AddComponent<GeneEngineDriver>(); GeneticsArtifactPlugin.geneticLogSource.LogWarning((object)"GeneEngineDriver Emergency Activation! Wasn't ready for a body yet."); } if ((int)self.teamComponent.teamIndex == 2 && Object.op_Implicit((Object)(object)self.inventory)) { if (!masterGenes.Exists((MasterGeneBehaviour x) => x.bodyIndex == self.bodyIndex)) { MasterGeneBehaviour masterGeneBehaviour = new MasterGeneBehaviour(); masterGeneBehaviour.Init(); masterGeneBehaviour.bodyIndex = self.bodyIndex; masterGenes.Add(masterGeneBehaviour); GeneticsArtifactPlugin.geneticLogSource.LogInfo((object)("Generated a Master Template for: " + BodyCatalog.GetBodyName(self.bodyIndex))); } MonsterGeneBehaviour monsterGeneBehaviour = ((Component)self).gameObject.AddComponent<MonsterGeneBehaviour>(); if (((Object)(object)RunArtifactManager.instance != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(ArtifactOfGenetics.artifactDef)) || ConfigManager.researchAutoRotateDdaAlgorithms.Value) { monsterGeneBehaviour.MutateFromMaster(); monsterGeneBehaviour.characterBody.RecalculateStats(); } else { monsterGeneBehaviour.CopyFromMaster(); } } } private static void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { orig.Invoke(self, damageInfo); if (!NetworkServer.active || !DdaAlgorithmState.ShouldRunGeneticEngine()) { return; } GameObject attacker = damageInfo.attacker; if (attacker != null) { if (!((Object)(object)attacker != (Object)null)) { return; } CharacterBody attackerBody = attacker.GetComponent<CharacterBody>(); if (attackerBody == null || !((Object)(object)attackerBody != (Object)null)) { return; } Inventory inventory = attackerBody.inventory; if (inventory != null && inventory.GetItemCount(GeneTokens.blockerDef) == 0) { MonsterGeneBehaviour monsterGeneBehaviour = livingGenes.Find((MonsterGeneBehaviour x) => (Object)(object)x.characterBody == (Object)(object)attackerBody); if ((Object)(object)monsterGeneBehaviour != (Object)null) { monsterGeneBehaviour.damageDealt += damageInfo.damage; } } return; } GameObject inflictor = damageInfo.inflictor; if (inflictor == null) { return; } if (!((Object)(object)inflictor != (Object)null)) { return; } CharacterBody inflictorBody = inflictor.GetComponent<CharacterBody>(); if (inflictorBody == null || !((Object)(object)inflictorBody != (Object)null)) { return; } Inventory inventory2 = inflictorBody.inventory; if (inventory2 != null && inventory2.GetItemCount(GeneTokens.blockerDef) == 0) { MonsterGeneBehaviour monsterGeneBehaviour2 = livingGenes.Find((MonsterGeneBehaviour x) => (Object)(object)x.characterBody == (Object)(object)inflictorBody); if ((Object)(object)monsterGeneBehaviour2 != (Object)null) { monsterGeneBehaviour2.damageDealt += damageInfo.damage; } } } public void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } if (NetworkServer.active) { masterGenes = new List<MasterGeneBehaviour>(); livingGenes = new List<MonsterGeneBehaviour>(); deadGenes = new List<MonsterGeneBehaviour>(); RegenerateGeneLimitOverrides(); } } public void Update() { if (!NetworkServer.active) { return; } timeSinceLastLearning += Time.deltaTime; switch (ConfigManager.governorType.Value) { case 1: if (timeSinceLastLearning >= (float)ConfigManager.timeLimit.Value) { Learn(); } break; case 2: if (deadGenes.Count >= ConfigManager.deathLimit.Value) { Learn(); } break; default: if (timeSinceLastLearning >= (float)ConfigManager.timeLimit.Value || deadGenes.Count >= ConfigManager.deathLimit.Value) { Learn(); } break; } } public void Learn() { foreach (MasterGeneBehaviour masterGene in masterGenes) { masterGene.MutateFromChildren(); } deadGenes.Clear(); timeSinceLastLearning = 0f; this.GEDPostLearningEvent?.Invoke(this, new EventArgs()); } public void RegenerateGeneLimitOverrides() { geneLimitOverrides = new Dictionary<GeneStat, (float, float)>(); if (!ConfigManager.enableGeneLimitOverrides.Value || string.IsNullOrEmpty(ConfigManager.geneLimitOverrides.Value)) { return; } string[] array = ConfigManager.geneLimitOverrides.Value.Trim().Split('|'); foreach (string text in array) { string[] array2 = text.Split(','); if (Enum.TryParse<GeneStat>(array2[0], ignoreCase: true, out var result) && float.TryParse(array2[1], out var result2) && result2 <= 1f && float.TryParse(array2[2], out var result3) && result3 >= 1f) { try { geneLimitOverrides.Add(result, (result2, result3)); GeneticsArtifactPlugin.geneticLogSource.LogInfo((object)("Adding Valid GeneOverride: " + text)); } catch { goto IL_00be; } continue; } goto IL_00be; IL_00be: GeneticsArtifactPlugin.geneticLogSource.LogWarning((object)("Skipping Invalid GeneOverride: " + text)); } } } public class GeneTokenCalc { public static void RegisterHooks() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients); } private static void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args) { Inventory inventory = sender.inventory; if (inventory != null && inventory.GetItemCount(GeneTokens.blockerDef) == 0) { args.baseHealthAdd += GetStatValueToAdd(sender, GeneStat.MaxHealth); args.baseMoveSpeedAdd += GetStatValueToAdd(sender, GeneStat.MoveSpeed); args.baseAttackSpeedAdd += GetStatValueToAdd(sender, GeneStat.AttackSpeed); args.baseDamageAdd += GetStatValueToAdd(sender, GeneStat.AttackDamage); } } public static float GetGeneMultiplier(CharacterBody body, GeneStat statType) { float num = 0.01f; Inventory inventory = body.inventory; float num2 = 1f + (num * (float?)((inventory != null) ? new int?(inventory.GetItemCount(GeneTokens.tokenDict[statType][GeneMod.Plus1])) : null)).GetValueOrDefault(); num = 0.01f; Inventory inventory2 = body.inventory; return num2 - (num * (float?)((inventory2 != null) ? new int?(inventory2.GetItemCount(GeneTokens.tokenDict[statType][GeneMod.Minus1])) : null)).GetValueOrDefault(); } public static float GetStatValueToAdd(CharacterBody body, GeneStat statType) { float num = 0f; switch (statType) { case GeneStat.MaxHealth: num = body.baseMaxHealth + body.levelMaxHealth * body.level; break; case GeneStat.MoveSpeed: num = body.baseMoveSpeed + body.levelMoveSpeed * body.level; break; case GeneStat.AttackSpeed: num = body.baseAttackSpeed + body.levelAttackSpeed * body.level; break; case GeneStat.AttackDamage: num = body.baseDamage + body.levelDamage * body.level; break; } return num * GetGeneMultiplier(body, statType) - num; } public static Dictionary<ItemDef, int> GetTokensToAdd(Dictionary<GeneStat, float> oldValues, Dictionary<GeneStat, float> newValues) { Dictionary<ItemDef, int> dictionary = new Dictionary<ItemDef, int>(); Dictionary<GeneStat, float> dictionary2 = new Dictionary<GeneStat, float>(); foreach (GeneStat value in Enum.GetValues(typeof(GeneStat))) { dictionary2.Add(value, newValues[value] - oldValues[value]); } foreach (GeneStat value2 in Enum.GetValues(typeof(GeneStat))) { if (dictionary2[value2] > 0f) { dictionary.Add(GeneTokens.tokenDict[value2][GeneMod.Plus1], (int)(dictionary2[value2] * 100f)); } else { dictionary.Add(GeneTokens.tokenDict[value2][GeneMod.Minus1], (int)(dictionary2[value2] * -100f)); } } return dictionary; } } public class GeneTokens { public static Dictionary<GeneStat, Dictionary<GeneMod, ItemDef>> tokenDict; public static ItemDef blockerDef; public static void Init() { LanguageAPI.Add("GENETIC_EMPTY_TOKEN", "This is better than null I guess"); tokenDict = new Dictionary<GeneStat, Dictionary<GeneMod, ItemDef>>(); foreach (GeneStat value in Enum.GetValues(typeof(GeneStat))) { tokenDict.Add(value, new Dictionary<GeneMod, ItemDef>()); foreach (GeneMod value2 in Enum.GetValues(typeof(GeneMod))) { ItemDef val = ScriptableObject.CreateInstance<ItemDef>(); ((Object)val).name = "GENETOKEN_" + value.ToString().ToUpper() + "_" + value2.ToString().ToUpper(); val.nameToken = "GENETIC_EMPTY_TOKEN"; val.pickupToken = "GENETIC_EMPTY_TOKEN"; val.descriptionToken = "GENETIC_EMPTY_TOKEN"; val.loreToken = "GENETIC_EMPTY_TOKEN"; val.pickupIconSprite = null; val.pickupModelPrefab = null; val.tags = (ItemTag[])(object)new ItemTag[2] { (ItemTag)13, (ItemTag)12 }; Reflection.SetFieldValue<ItemTier>((object)val, "deprecatedTier", (ItemTier)5); val.hidden = true; val.canRemove = false; ContentAddition.AddItemDef(val); tokenDict[value].Add(value2, val); } } blockerDef = ScriptableObject.CreateInstance<ItemDef>(); ((Object)blockerDef).name = "GENETOKEN_BLOCKER"; blockerDef.nameToken = "GENETIC_EMPTY_TOKEN"; blockerDef.pickupToken = "GENETIC_EMPTY_TOKEN"; blockerDef.descriptionToken = "GENETIC_EMPTY_TOKEN"; blockerDef.loreToken = "GENETIC_EMPTY_TOKEN"; blockerDef.pickupIconSprite = null; blockerDef.pickupModelPrefab = null; blockerDef.tags = (ItemTag[])(object)new ItemTag[2] { (ItemTag)13, (ItemTag)12 }; Reflection.SetFieldValue<ItemTier>((object)blockerDef, "deprecatedTier", (ItemTier)5); blockerDef.hidden = true; blockerDef.canRemove = false; ContentAddition.AddItemDef(blockerDef); } } public enum GeneStat { MaxHealth, MoveSpeed, AttackSpeed, AttackDamage } public enum GeneMod { Plus1, Minus1 } public class MasterGeneBehaviour { public BodyIndex bodyIndex; public Dictionary<GeneStat, float> templateGenes; public event EventHandler MaGBPostCreationEvent; public event EventHandler MaGBPostMutationEvent; public void Init() { templateGenes = new Dictionary<GeneStat, float>(); foreach (GeneStat value in Enum.GetValues(typeof(GeneStat))) { templateGenes.Add(value, 1f); } this.MaGBPostCreationEvent?.Invoke(this, new EventArgs()); } public void MutateFromChildren() { List<MonsterGeneBehaviour> list = GeneEngineDriver.deadGenes.Where((MonsterGeneBehaviour x) => x.bodyIndex == bodyIndex && x.score > 0f).ToList(); foreach (GeneStat value in Enum.GetValues(typeof(GeneStat))) { float num = 0f; float num2 = 0f; foreach (MonsterGeneBehaviour item in list) { num2 += item.currentGenes[value] * item.score; num += item.score; } if (num > 0f) { templateGenes[value] = (float)decimal.Round((decimal)(num2 / num), 2); } } this.MaGBPostMutationEvent?.Invoke(this, new EventArgs()); } } public class MonsterGeneBehaviour : MonoBehaviour { public BodyIndex bodyIndex; public Dictionary<GeneStat, float> currentGenes; public CharacterBody characterBody; public float timeAlive; public float timeEngaged; public float damageDealt; public float score; public event EventHandler MoGBPostMutationEvent; public event EventHandler MoGBPostScoringEvent; public void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) characterBody = ((Component)this).gameObject.GetComponent<CharacterBody>(); bodyIndex = characterBody.bodyIndex; InitializeCurrentGenes(); GeneEngineDriver.livingGenes.Add(this); } public void Update() { timeAlive += Time.deltaTime; if (!characterBody.outOfCombat) { timeEngaged += Time.deltaTime; } } public void MutateFromMaster() { CopyFromMaster(); MutateSelf(); } public void CopyFromMaster() { MasterGeneBehaviour masterGeneBehaviour = GeneEngineDriver.masterGenes.Find((MasterGeneBehaviour x) => x.bodyIndex == bodyIndex); AdaptToNewGenes(masterGeneBehaviour.templateGenes); } public void MutateSelf() { Dictionary<GeneStat, float> attempt = GenerateMutationAttempt(); attempt = CorrectOvermutation(attempt); AdaptToNewGenes(attempt); this.MoGBPostMutationEvent?.Invoke(this, new EventArgs()); } private Dictionary<GeneStat, float> CorrectOvermutation(Dictionary<GeneStat, float> attempt) { while (CalculateGeneProduct(attempt) > ConfigManager.geneProductLimit.Value) { attempt[attempt.Aggregate((KeyValuePair<GeneStat, float> x, KeyValuePair<GeneStat, float> y) => (!(x.Value > y.Value)) ? y : x).Key] -= 0.05f; } return attempt; } private float CalculateGeneProduct(Dictionary<GeneStat, float> testValues) { float num = 1f; foreach (float value in testValues.Values) { num *= value; } return num; } public void LogDebugInfo() { GeneticsArtifactPlugin.geneticLogSource.LogInfo((object)(Stage.instance.sceneDef.baseSceneName + " " + ((Object)characterBody).name + " " + currentGenes[GeneStat.MaxHealth] + " " + currentGenes[GeneStat.MoveSpeed] + " " + currentGenes[GeneStat.AttackSpeed] + " " + currentGenes[GeneStat.AttackDamage])); } private void InitializeCurrentGenes() { currentGenes = new Dictionary<GeneStat, float>(); foreach (GeneStat value in Enum.GetValues(typeof(GeneStat))) { currentGenes.Add(value, 1f); } } public void AdaptToNewGenes(Dictionary<GeneStat, float> newGenes) { foreach (KeyValuePair<ItemDef, int> item in GeneTokenCalc.GetTokensToAdd(currentGenes, newGenes)) { characterBody.inventory.GiveItem(item.Key, item.Value); } currentGenes = newGenes; } private Dictionary<GeneStat, float> GenerateMutationAttempt() { Dictionary<GeneStat, float> dictionary = new Dictionary<GeneStat, float>(); float num = ConfigManager.geneVarianceLimit.Value * (float)((!(Stage.instance.sceneDef.baseSceneName == "artifactworld")) ? 1 : 5); foreach (GeneStat key in currentGenes.Keys) { float num2 = currentGenes[key]; if (ConfigManager.enableGeneLimitOverrides.Value && GeneEngineDriver.geneLimitOverrides.ContainsKey(key)) { dictionary.Add(key, (float)decimal.Round((decimal)Mathf.Clamp(Random.Range(num2 * (1f - num), num2 * (1f + num)), GeneEngineDriver.geneLimitOverrides[key].Item1, GeneEngineDriver.geneLimitOverrides[key].Item2), 2)); } else { dictionary.Add(key, (float)decimal.Round((decimal)Mathf.Clamp(Random.Range(num2 * (1f - num), num2 * (1f + num)), ConfigManager.geneFloor.Value, ConfigManager.geneCap.Value), 2)); } } return dictionary; } private void OnDestroy() { ScoreMe(); GeneEngineDriver.livingGenes.Remove(this); GeneEngineDriver.deadGenes.Add(this); } public float ScoreMe() { score = 0f; if (timeAlive > 0f && timeEngaged > 0f) { float num = timeEngaged / timeAlive; score = damageDealt * num; } this.MoGBPostScoringEvent?.Invoke(this, new EventArgs()); return score; } } [BepInPlugin("com.RicoValdezio.ArtifactOfGenetics", "Genetics", "4.5.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class GeneticsArtifactPlugin : BaseUnityPlugin { public const string ModVer = "4.5.4"; public const string ModName = "Genetics"; public const string ModGuid = "com.RicoValdezio.ArtifactOfGenetics"; public static GeneticsArtifactPlugin Instance; public static ManualLogSource geneticLogSource; public static AssetBundle geneticAssetBundle; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } geneticLogSource = ((BaseUnityPlugin)Instance).Logger; geneticAssetBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("GeneticsArtifact.ArtifactResources.genetics")); ConfigManager.Init(((BaseUnityPlugin)this).Config); DdaCheatManager.Init(); ArtifactOfGenetics.Init(); GeneTokens.Init(); ManualLogSource obj = geneticLogSource; if (obj != null) { obj.LogInfo((object)("[DDA] Diagnostics flags: GeneTokenCalc=" + ConfigManager.diagnosticsEnableGeneTokenCalcHooks.Value + ", GeneticEngine=" + ConfigManager.diagnosticsEnableGeneticEngineHooks.Value + ", SGD=" + ConfigManager.diagnosticsEnableSgdHooks.Value + ", SgdActuators=" + ConfigManager.diagnosticsEnableSgdActuatorsHooks.Value + ", Telemetry=" + ConfigManager.diagnosticsEnableTelemetryHooks.Value + ", Rotator=" + ConfigManager.diagnosticsEnableRunModeRotatorHooks.Value)); } if (ConfigManager.diagnosticsEnableGeneTokenCalcHooks.Value) { GeneTokenCalc.RegisterHooks(); } if (ConfigManager.diagnosticsEnableGeneticEngineHooks.Value) { GeneEngineDriver.RegisterHooks(); } if (ConfigManager.diagnosticsEnableSgdHooks.Value) { SgdRuntimeDriver.RegisterHooks(); } if (ConfigManager.diagnosticsEnableSgdActuatorsHooks.Value) { SgdActuatorsHooks.RegisterHooks(); } if (ConfigManager.diagnosticsEnableTelemetryHooks.Value) { TelemetryRuntimeDriver.RegisterHooks(); } if (ConfigManager.diagnosticsEnableRunModeRotatorHooks.Value) { DdaRunModeRotator.RegisterHooks(); } foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value.Metadata.GUID.Equals("com.rune580.riskofoptions")) { RiskOfOptionsCompat.Init(); break; } } } } } namespace GeneticsArtifact.Telemetry { internal static class PostHogBatchClient { [CompilerGenerated] private sealed class <FlushAllQueuedEvents>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int maxBatches; public float maxSeconds; private float <startedAt>5__2; private int <batches>5__3; private int <before>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FlushAllQueuedEvents>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!ConfigManager.telemetryEnabled.Value) { return false; } <startedAt>5__2 = Time.realtimeSinceStartup; <batches>5__3 = 0; break; case 1: <>1__state = -1; <batches>5__3++; if (TelemetryEventQueue.Count >= <before>5__4) { return false; } <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; break; } if (TelemetryEventQueue.Count > 0) { if (<batches>5__3 >= maxBatches) { ManualLogSource geneticLogSource = GeneticsArtifactPlugin.geneticLogSource; if (geneticLogSource != null) { geneticLogSource.LogWarning((object)("[Telemetry] PostHog flush stopped: maxBatches reached (" + maxBatches + "). Remaining=" + TelemetryEventQueue.Count)); } return false; } if (Time.realtimeSinceStartup - <startedAt>5__2 > maxSeconds) { ManualLogSource geneticLogSource2 = GeneticsArtifactPlugin.geneticLogSource; if (geneticLogSource2 != null) { geneticLogSource2.LogWarning((object)("[Telemetry] PostHog flush stopped: timeout (" + maxSeconds + "s). Remaining=" + TelemetryEventQueue.Count)); } return false; } <before>5__4 = TelemetryEventQueue.Count; <>2__current = FlushQueuedEvents(); <>1__state = 1; return true; } 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(); } } [CompilerGenerated] private sealed class <FlushQueuedEvents>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FlushQueuedEvents>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Invalid comparison between Unknown and I4 //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Invalid comparison between Unknown and I4 //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (!ConfigManager.telemetryEnabled.Value) { return false; } string text = "phc_oHSq642PWWQmaTGWDzmrvyHUm5BuuSkQaKgbStJBD9Sw"; if (string.IsNullOrWhiteSpace(text)) { return false; } if (!TelemetryEventQueue.TryDequeueBatchAsPostHogJson(text, out var payload, out var _)) { return false; } if (string.IsNullOrEmpty(payload)) { return false; } string text2 = NormalizeHost("https://us.i.posthog.com"); byte[] bytes = Encoding.UTF8.GetBytes(payload); <request>5__2 = new UnityWebRequest(text2 + "/batch/", "POST"); <>1__state = -3; <request>5__2.uploadHandler = (UploadHandler)new UploadHandlerRaw(bytes); <request>5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); <request>5__2.SetRequestHeader("Content-Type", "application/json"); <request>5__2.timeout = 5; <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: <>1__state = -3; if ((int)<request>5__2.result == 2 || (int)<request>5__2.result == 3 || (int)<request>5__2.result == 4) { TelemetryEventQueue.RestoreLastBatchForRetry(); ManualLogSource geneticLogSource = GeneticsArtifactPlugin.geneticLogSource; if (geneticLogSource != null) { geneticLogSource.LogWarning((object)("[Telemetry] PostHog flush failed: " + <request>5__2.error)); } } else { TelemetryEventQueue.MarkLastBatchSent(); } <>m__Finally1(); <request>5__2 = null; return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<FlushAllQueuedEvents>d__0))] public static IEnumerator FlushAllQueuedEvents(float maxSeconds = 8f, int maxBatches = 64) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FlushAllQueuedEvents>d__0(0) { maxSeconds = maxSeconds, maxBatches = maxBatches }; } [IteratorStateMachine(typeof(<FlushQueuedEvents>d__1))] public static IEnumerator FlushQueuedEvents() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FlushQueuedEvents>d__1(0); } private static string NormalizeHost(string host) { if (string.IsNullOrWhiteSpace(host)) { return "https://us.i.posthog.com"; } host = host.Trim(); while (host.EndsWith("/")) { host = host.Substring(0, host.Length - 1); } return host; } } internal readonly struct TelemetryDifficultySnapshot { public readonly string Mode; public readonly float MaxHealth; public readonly float MoveSpeed; public readonly float AttackSpeed; public readonly float AttackDamage; public TelemetryDifficultySnapshot(string mode, float maxHealth, float moveSpeed, float attackSpeed, float attackDamage) { Mode = mode; MaxHealth = Sanitize(maxHealth); MoveSpeed = Sanitize(moveSpeed); AttackSpeed = Sanitize(attackSpeed); AttackDamage = Sanitize(attackDamage); } public static TelemetryDifficultySnapshot Capture() { string telemetryMode = DdaAlgorithmState.GetTelemetryMode(); if (telemetryMode == "SGD") { return new TelemetryDifficultySnapshot(telemetryMode, SgdActuatorsRuntimeState.MaxHealthMultiplier, SgdActuatorsRuntimeState.MoveSpeedMultiplier, SgdActuatorsRuntimeState.AttackSpeedMultiplier, SgdActuatorsRuntimeState.AttackDamageMultiplier); } if (telemetryMode == "GA") { return CaptureGeneticAverages(); } return new TelemetryDifficultySnapshot(telemetryMode, 1f, 1f, 1f, 1f); } public float GetMultiplier(GeneStat stat) { return stat switch { GeneStat.MaxHealth => MaxHealth, GeneStat.MoveSpeed => MoveSpeed, GeneStat.AttackSpeed => AttackSpeed, GeneStat.AttackDamage => AttackDamage, _ => 1f, }; } private static TelemetryDifficultySnapshot CaptureGeneticAverages() { float hp = 0f; float ms = 0f; float attackSpeed = 0f; float attackDamage = 0f; int count = 0; if (GeneEngineDriver.masterGenes != null) { for (int i = 0; i < GeneEngineDriver.masterGenes.Count; i++) { MasterGeneBehaviour masterGeneBehaviour = GeneEngineDriver.masterGenes[i]; if (masterGeneBehaviour?.templateGenes != null) { AddGenes(masterGeneBehaviour.templateGenes, ref hp, ref ms, ref attackSpeed, ref attackDamage, ref count); } } } if (count == 0 && GeneEngineDriver.livingGenes != null) { for (int j = 0; j < GeneEngineDriver.livingGenes.Count; j++) { MonsterGeneBehaviour monsterGeneBehaviour = GeneEngineDriver.livingGenes[j]; if (monsterGeneBehaviour?.currentGenes != null) { AddGenes(monsterGeneBehaviour.currentGenes, ref hp, ref ms, ref attackSpeed, ref attackDamage, ref count); } } } if (count <= 0) { return new TelemetryDifficultySnapshot("GA", 1f, 1f, 1f, 1f); } return new TelemetryDifficultySnapshot("GA", hp / (float)count, ms / (float)count, attackSpeed / (float)count, attackDamage / (float)count); } private static void AddGenes(Dictionary<GeneStat, float> genes, ref float hp, ref float ms, ref float attackSpeed, ref float attackDamage, ref int count) { hp += GetGeneOrDefault(genes, GeneStat.MaxHealth); ms += GetGeneOrDefault(genes, GeneStat.MoveSpeed); attackSpeed += GetGeneOrDefault(genes, GeneStat.AttackSpeed); attackDamage += GetGeneOrDefault(genes, GeneStat.AttackDamage); count++; } private static float GetGeneOrDefault(Dictionary<GeneStat, float> genes, GeneStat stat) { if (genes == null || !genes.TryGetValue(stat, out var value)) { return 1f; } return Sanitize(value); } private static float Sanitize(float value) { if (float.IsNaN(value) || float.IsInfinity(value) || value <= 0f) { return 1f; } return Mathf.Clamp(value, 0.0001f, 100f); } } internal sealed class TelemetryEvent { public string EventName { get; } public DateTime TimestampUtc { get; } public Dictionary<string, object> Properties { get; } public TelemetryEvent(string eventName, Dictionary<string, object> properties) { EventName = eventName; TimestampUtc = DateTime.UtcNow; Properties = properties ?? new Dictionary<string, object>(); } } internal static class TelemetryEventQueue { private const int DefaultBatchSize = 32; private static readonly Queue<TelemetryEvent> Events = new Queue<TelemetryEvent>(128); private static List<TelemetryEvent> _lastBatch; private static TelemetryEvent _lastEnqueuedEvent; private static TelemetryEvent _lastEnqueuedSample; public static int Count => Events.Count; public static TelemetryEvent LastEnqueuedEvent => _lastEnqueuedEvent; public static TelemetryEvent LastEnqueuedSample => _lastEnqueuedSample; public static void Enqueue(TelemetryEvent telemetryEvent) { if (telemetryEvent != null) { _lastEnqueuedEvent = telemetryEvent; if (telemetryEvent.EventName == "dda_sample") { _lastEnqueuedSample = telemetryEvent; } int num = ConfigManager.telemetryMaxQueueSize?.Value ?? 512; num = Mathf.Clamp(num, 32, 5000); while (Events.Count >= num) { Events.Dequeue(); } Events.Enqueue(telemetryEvent); } } public static bool TryDequeueBatchAsPostHogJson(string projectToken, out string payload, out int batchCount) { payload = ""; batchCount = 0; if (string.IsNullOrWhiteSpace(projectToken) || Events.Count == 0) { return false; } int num = (batchCount = Mathf.Min(32, Events.Count)); _lastBatch = new List<TelemetryEvent>(num); for (int i = 0; i < num; i++) { _lastBatch.Add(Events.Dequeue()); } payload = TelemetryJsonWriter.BuildPostHogBatch(projectToken.Trim(), _lastBatch); return !string.IsNullOrEmpty(payload); } public static string DequeueBatchAsPostHogJson(string projectToken) { if (!TryDequeueBatchAsPostHogJson(projectToken, out var payload, out var _)) { return ""; } return payload; } public static void MarkLastBatchSent() { _lastBatch = null; } public static void RestoreLastBatchForRetry() { if (_lastBatch != null && _lastBatch.Count != 0) { _ = _lastBatch.Count; for (int i = 0; i < _lastBatch.Count; i++) { Events.Enqueue(_lastBatch[i]); } _lastBatch = null; } } } internal static class TelemetryJsonWriter { public static string BuildPostHogBatch(string apiKey, IReadOnlyList<TelemetryEvent> events) { StringBuilder stringBuilder = new StringBuilder(4096); stringBuilder.Append('{'); WritePropertyName(stringBuilder, "api_key"); WriteString(stringBuilder, apiKey); stringBuilder.Append(','); WritePropertyName(stringBuilder, "historical_migration"); stringBuilder.Append("false"); stringBuilder.Append(','); WritePropertyName(stringBuilder, "batch"); stringBuilder.Append('['); for (int i = 0; i < events.Count; i++) { if (i > 0) { stringBuilder.Append(','); } WriteEvent(stringBuilder, events[i]); } stringBuilder.Append(']'); stringBuilder.Append('}'); return stringBuilder.ToString(); } private static void WriteEvent(StringBuilder sb, TelemetryEvent telemetryEvent) { sb.Append('{'); WritePropertyName(sb, "event"); WriteString(sb, telemetryEvent.EventName); sb.Append(','); WritePropertyName(sb, "timestamp"); WriteString(sb, telemetryEvent.TimestampUtc.ToString("O", CultureInfo.InvariantCulture)); sb.Append(','); WritePropertyName(sb, "properties"); WriteDictionary(sb, telemetryEvent.Properties); sb.Append('}'); } private static void WriteDictionary(StringBuilder sb, Dictionary<string, object> values) { sb.Append('{'); bool flag = true; foreach (KeyValuePair<string, object> value in values) { if (!flag) { sb.Append(','); } flag = false; WritePropertyName(sb, value.Key); WriteValue(sb, value.Value); } sb.Append('}'); } private static void WritePropertyName(StringBuilder sb, string name) { WriteString(sb, name); sb.Append(':'); } private static void WriteValue(StringBuilder sb, object value) { if (value == null) { sb.Append("null"); } else if (value is string value2) { WriteString(sb, value2); } else if (value is bool flag) { sb.Append(flag ? "true" : "false"); } else if (value is int || value is long || value is short || value is byte) { sb.Append(Convert.ToString(value, CultureInfo.InvariantCulture)); } else if (value is float value3) { WriteFloat(sb, value3); } else if (value is double value4) { WriteDouble(sb, value4); } else { WriteString(sb, Convert.ToString(value, CultureInfo.InvariantCulture)); } } private static void WriteFloat(StringBuilder sb, float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { sb.Append('0'); } else { sb.Append(value.ToString("R", CultureInfo.InvariantCulture)); } } private static void WriteDouble(StringBuilder sb, double value) { if (double.IsNaN(value) || double.IsInfinity(value)) { sb.Append('0'); } else { sb.Append(value.ToString("R", CultureInfo.InvariantCulture)); } } private static void WriteString(StringBuilder sb, string value) { sb.Append('"'); if (!string.IsNullOrEmpty(value)) { foreach (char c in value) { switch (c) { case '\\': sb.Append("\\\\"); continue; case '"': sb.Append("\\\""); continue; case '\n': sb.Append("\\n"); continue; case '\r': sb.Append("\\r"); continue; case '\t': sb.Append("\\t"); continue; } if (c < ' ') { sb.Append("\\u"); int num = c; sb.Append(num.ToString("x4", CultureInfo.InvariantCulture)); } else if (c > '\u007f') { sb.Append("\\u"); int num = c; sb.Append(num.ToString("x4", CultureInfo.InvariantCulture)); } else { sb.Append(c); } } } sb.Append('"'); } } internal sealed class TelemetryRuntimeDriver : MonoBehaviour { [CompilerGenerated] private sealed class <FlushRoutine>d__31 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TelemetryRuntimeDriver <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FlushRoutine>d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; TelemetryRuntimeDriver telemetryRuntimeDriver = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; telemetryRuntimeDriver._isFlushing = true; <>2__current = PostHogBatchClient.FlushQueuedEvents(); <>1__state = 1; return true; case 1: <>1__state = -1; telemetryRuntimeDriver._isFlushing = false; 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(); } } private static TelemetryRuntimeDriver _activeDriver; private static TelemetrySessionState _pendingSurveySession; private static string _pendingSurveyEndReason = ""; private static bool _pendingSessionEndQueued; private readonly TelemetrySessionState _session = new TelemetrySessionState(); private float _sampleTimer; private float _flushTimer; private float _lastPlayerDeathAt = -1000f; private bool _isFlushing; public static bool HasActiveSession => GetSurveySession() != null; public static bool HasSubmittedSurvey => GetSurveySession()?.HasSurveyCompleted ?? false; public static void RegisterHooks() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (ConfigManager.diagnosticsEnableSgdHooks == null || !ConfigManager.diagnosticsEnableSgdHooks.Value) { Run.BeginGameOver += new hook_BeginGameOver(Run_BeginGameOver); Run.Start += new hook_Start(Run_Start); CharacterBody.OnDestroy += new hook_OnDestroy(CharacterBody_OnDestroy); } BaseMainMenuScreen.OnEnter += new hook_OnEnter(BaseMainMenuScreen_OnEnter); } internal static void NotifyRunBeginGameOver(GameEndingDef gameEndingDef) { RequestSurvey(((Object)(object)gameEndingDef != (Object)null && gameEndingDef.isWin) ? "victory" : "game_over"); } internal static void NotifyPlayerBodyDestroyed(CharacterBody body) { if (!((Object)(object)_activeDriver == (Object)null) && ConfigManager.telemetryEnabled.Value && !((Object)(object)body == (Object)null) && IsPlayerBody(body) && !(Time.time - _activeDriver._lastPlayerDeathAt < 1f)) { _activeDriver._lastPlayerDeathAt = Time.time; _activeDriver._session.RecordPlayerDeath(); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildPlayerDeath(_activeDriver._session, body, null)); RequestSurvey("player_death"); _activeDriver.StartFlushIfIdle(); } } public static bool RecordPostSessionSurvey(int fairnessLikert, int continuityLikert, string comment) { TelemetrySessionState surveySession = GetSurveySession(); if (surveySession == null) { return false; } surveySession.RecordSurvey(fairnessLikert, continuityLikert, comment); if (ConfigManager.telemetryEnabled.Value) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildPostSessionSurvey(surveySession, surveySession.SurveyFairnessLikert, surveySession.SurveyContinuityLikert, surveySession.SurveyComment)); if (!surveySession.HasSessionEndQueued) { surveySession.MarkSessionEndQueued(); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionEnd(surveySession, "post_session_survey_submitted")); } CompletePendingSessionEndIfNeeded(); StartAnyFlushIfPossible(); } return true; } public static void RequestSurvey(string triggerReason) { if (ConfigManager.telemetryEnabled.Value && HasActiveSession && !HasSubmittedSurvey) { TelemetrySurveyWidget.Show(triggerReason); } } public static void SkipPendingSurvey() { TelemetrySessionState surveySession = GetSurveySession(); if (surveySession != null && !surveySession.HasSurveyCompleted) { surveySession.RecordSurveySkipped("ui_trigger=unknown"); if (ConfigManager.telemetryEnabled.Value) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildPostSessionSurveySkipped(surveySession, surveySession.SurveyComment)); } } if (surveySession != null && !surveySession.HasSessionEndQueued) { surveySession.MarkSessionEndQueued(); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionEnd(surveySession, "post_session_survey_skipped")); } CompletePendingSessionEndIfNeeded(); StartAnyFlushIfPossible(); } public static void SkipPendingSurvey(string comment) { TelemetrySessionState surveySession = GetSurveySession(); if (surveySession != null && !surveySession.HasSurveyCompleted) { surveySession.RecordSurveySkipped(comment); if (ConfigManager.telemetryEnabled.Value) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildPostSessionSurveySkipped(surveySession, surveySession.SurveyComment)); } } if (surveySession != null && !surveySession.HasSessionEndQueued) { surveySession.MarkSessionEndQueued(); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionEnd(surveySession, "post_session_survey_skipped")); } CompletePendingSessionEndIfNeeded(); StartAnyFlushIfPossible(); } private static void Run_Start(orig_Start orig, Run self) { orig.Invoke(self); if ((Object)(object)self != (Object)null && (Object)(object)((Component)self).gameObject != (Object)null && (Object)(object)((Component)self).gameObject.GetComponent<TelemetryRuntimeDriver>() == (Object)null) { ((Component)self).gameObject.AddComponent<TelemetryRuntimeDriver>(); } } private static void Run_BeginGameOver(orig_BeginGameOver orig, Run self, GameEndingDef gameEndingDef) { RequestSurvey(((Object)(object)gameEndingDef != (Object)null && gameEndingDef.isWin) ? "victory" : "game_over"); orig.Invoke(self, gameEndingDef); } private static void BaseMainMenuScreen_OnEnter(orig_OnEnter orig, BaseMainMenuScreen self, MainMenuController mainMenuController) { orig.Invoke(self, mainMenuController); EnsureMpEventSystemForMainMenu(); Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; TryShowPendingSurveyFromMainMenu(); } private static void EnsureMpEventSystemForMainMenu() { try { MPEventSystem[] array = Object.FindObjectsOfType<MPEventSystem>(); EventSystem[] array2 = Object.FindObjectsOfType<EventSystem>(); MPEventSystem val = null; if (array != null) { MPEventSystem[] array3 = array; foreach (MPEventSystem val2 in array3) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name == "MPEventSystem Player0") { val = val2; break; } } if ((Object)(object)val == (Object)null) { array3 = array; foreach (MPEventSystem val3 in array3) { if ((Object)(object)val3 != (Object)null && ((Behaviour)val3).enabled) { val = val3; break; } } } if ((Object)(object)val == (Object)null && array.Length != 0) { val = array[0]; } } if ((Object)(object)val != (Object)null && !((Behaviour)val).enabled) { ((Behaviour)val).enabled = true; } if (!((Object)(object)val != (Object)null) || array2 == null) { return; } EventSystem[] array4 = array2; foreach (EventSystem val4 in array4) { if (!((Object)(object)val4 == (Object)null) && !(val4 is MPEventSystem) && ((Behaviour)val4).enabled) { ((Behaviour)val4).enabled = false; } } } catch (Exception ex) { ManualLogSource geneticLogSource = GeneticsArtifactPlugin.geneticLogSource; if (geneticLogSource != null) { geneticLogSource.LogWarning((object)("[DDA] EnsureMpEventSystemForMainMenu failed: " + ex.GetType().Name + ": " + ex.Message)); } } } private static void TryShowPendingSurveyFromMainMenu() { if (ConfigManager.telemetryEnabled.Value && _pendingSurveySession != null && !_pendingSurveySession.HasSurveyCompleted) { RequestSurvey("pending_survey_main_menu"); } } private void Awake() { _activeDriver = this; _session.StartNewRun(); _sampleTimer = 0f; _flushTimer = 0f; _lastPlayerDeathAt = -1000f; if (ConfigManager.telemetryEnabled.Value) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionStart(_session)); } } private void Update() { if (!ConfigManager.telemetryEnabled.Value) { return; } float deltaTime = Time.deltaTime; _sampleTimer += deltaTime; _flushTimer += deltaTime; float num = Mathf.Max(1f, ConfigManager.telemetrySampleIntervalSeconds.Value); if (_sampleTimer >= num) { float sampleTimer = _sampleTimer; int num2 = Mathf.Max(1, Mathf.FloorToInt(_sampleTimer / num)); _sampleTimer -= (float)num2 * num; _session.RecordMissedSampleIntervals(num2 - 1); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSample(_session, sampleTimer)); if (_session.TryConsumeRecoveryEvent(out var recoverySeconds)) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildRecovery(_session, recoverySeconds)); } TelemetryDegradationTransition transition; while (_session.TryConsumeDegradationTransition(out transition)) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildDegradationTransition(_session, transition)); } } float num3 = Mathf.Max(5f, ConfigManager.telemetryFlushIntervalSeconds.Value); if (_flushTimer >= num3) { _flushTimer = 0f; StartFlushIfIdle(); } } private void OnDestroy() { if (ConfigManager.telemetryEnabled.Value && !string.IsNullOrEmpty(_session.SessionId)) { if (_session.HasSurvey) { if (!_session.HasSessionEndQueued) { _session.MarkSessionEndQueued(); TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionEnd(_session, "run_destroyed")); } if ((Object)(object)GeneticsArtifactPlugin.Instance != (Object)null) { ((MonoBehaviour)GeneticsArtifactPlugin.Instance).StartCoroutine(PostHogBatchClient.FlushQueuedEvents()); } } else { _pendingSurveySession = _session; _pendingSurveyEndReason = "run_destroyed"; _pendingSessionEndQueued = false; } } if ((Object)(object)_activeDriver == (Object)(object)this) { _activeDriver = null; } } private static void CharacterBody_OnDestroy(orig_OnDestroy orig, CharacterBody self) { try { if (!((Object)(object)_activeDriver == (Object)null) && ConfigManager.telemetryEnabled.Value && !((Object)(object)self == (Object)null) && IsPlayerBody(self) && !(Time.time - _activeDriver._lastPlayerDeathAt < 1f)) { NotifyPlayerBodyDestroyed(self); } } finally { orig.Invoke(self); } } private static bool IsPlayerBody(CharacterBody body) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if ((Object)(object)body != (Object)null) { if (!body.isPlayerControlled) { if ((Object)(object)body.teamComponent != (Object)null) { return (int)body.teamComponent.teamIndex == 1; } return false; } return true; } return false; } private void StartFlushIfIdle() { if (!_isFlushing) { ((MonoBehaviour)this).StartCoroutine(FlushRoutine()); } } [IteratorStateMachine(typeof(<FlushRoutine>d__31))] private IEnumerator FlushRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FlushRoutine>d__31(0) { <>4__this = this }; } private static TelemetrySessionState GetSurveySession() { if ((Object)(object)_activeDriver != (Object)null && !string.IsNullOrEmpty(_activeDriver._session.SessionId)) { return _activeDriver._session; } if (_pendingSurveySession == null || string.IsNullOrEmpty(_pendingSurveySession.SessionId)) { return null; } return _pendingSurveySession; } private static void CompletePendingSessionEndIfNeeded() { if (_pendingSurveySession != null && !_pendingSessionEndQueued) { TelemetryEventQueue.Enqueue(TelemetrySampleBuilder.BuildSessionEnd(_pendingSurveySession, _pendingSurveyEndReason)); _pendingSessionEndQueued = true; _pendingSurveySession = null; _pendingSurveyEndReason = ""; } } private static void StartAnyFlushIfPossible() { if ((Object)(object)_activeDriver != (Object)null) { _activeDriver.StartFlushIfIdle(); } else if ((Object)(object)GeneticsArtifactPlugin.Instance != (Object)null) { ((MonoBehaviour)GeneticsArtifactPlugin.Instance).StartCoroutine(PostHogBatchClient.FlushQueuedEvents()); } } } internal static class TelemetrySampleBuilder { [CompilerGenerated] private sealed class <EnumerateAcquiredItems>d__20 : IEnumerable<ItemIndex>, IEnumerable, IEnumerator<ItemIndex>, IEnumerator, IDisposable { private int <>1__state; private ItemIndex <>2__current; private int <>l__initialThreadId; private Inventory inventory; public Inventory <>3__inventory; private IEnumerator <>7__wrap1; ItemIndex IEnumerator<ItemIndex>.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } [DebuggerHidden] public <EnumerateAcquiredItems>d__20(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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) //IL_009e: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)inventory == (Object)null) { return false; } if (!(typeof(Inventory).GetField("itemAcquisitionOrder", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(inventory) is IEnumerable enumerable)) { return false; } <>7__wrap1 = enumerable.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { if (<>7__wrap1.Current is ItemIndex val) { <>2__current = val; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 is IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ItemIndex> IEnumerable<ItemIndex>.GetEnumerator() { <EnumerateAcquiredItems>d__20 <EnumerateAcquiredItems>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <EnumerateAcquiredItems>d__ = this; } else { <EnumerateAcquiredItems>d__ = new <EnumerateAcquiredItems>d__20(0); } <EnumerateAcquiredItems>d__.inventory = <>3__inventory; return <EnumerateAcquiredItems>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ItemIndex>)this).GetEnumerator(); } } public static TelemetryEvent BuildSessionStart(TelemetrySessionState session) { Dictionary<string, object> dictionary = BuildCommonProperties(session); dictionary["event_kind"] = "session_start"; dictionary["telemetry_enabled"] = ConfigManager.telemetryEnabled.Value; dictionary["sample_interval_seconds"] = ConfigManager.telemetrySampleIntervalSeconds.Value; dictionary["flush_interval_seconds"] = ConfigManager.telemetryFlushIntervalSeconds.Value; return new TelemetryEvent("dda_session_start", dictionary); } public static TelemetryEvent BuildSample(TelemetrySessionState session, float dt) { Dictionary<string, object> dictionary = BuildCommonProperties(session); SgdSensorsSample s = (SgdSensorsRuntimeState.HasSample ? SgdSensorsRuntimeState.Sample : default(SgdSensorsSample)); SgdVirtualPowerSample sgdVirtualPowerSample = (SgdRuntimeState.HasVirtualPower ? SgdRuntimeState.VirtualPower : default(SgdVirtualPowerSample)); TelemetryDifficultySnapshot snapshot = TelemetryDifficultySnapshot.Capture(); AddSensorProperties(dictionary, in s); float num = EstimateMaxHealthSkill01(in s); float num2 = EstimateMoveSpeedSkill01(in s); float num3 = EstimateAttackSpeedSkill01(in s); float num4 = EstimateAttackDamageSkill01(in s); float num5 = Challenge01(GeneStat.MaxHealth, snapshot.MaxHealth); float num6 = Challenge01(GeneStat.MoveSpeed, snapshot.MoveSpeed); float num7 = Challenge01(GeneStat.AttackSpeed, snapshot.AttackSpeed); float num8 = Challenge01(GeneStat.AttackDamage, snapshot.AttackDamage); float num9 = num5 - num; flo