public static bool Prefix(ref Task <Profile> __result, BotsPresets __instance, BotData data) { /* * in short when client wants new bot and GetNewProfile() return null (if not more available templates or they don't satisfied by Role and Difficulty condition) * then client gets new piece of WaveInfo collection (with Limit = 30 by default) and make request to server * but use only first value in response (this creates a lot of garbage and cause freezes) * after patch we request only 1 template from server * * along with other patches this one causes to call data.PrepareToLoadBackend(1) gets the result with required role and difficulty: * new[] { new WaveInfo() { Limit = 1, Role = role, Difficulty = difficulty } } * then perform request to server and get only first value of resulting single element collection */ var session = _sessionField(__instance); if (session == null) { throw new InvalidOperationException("Something went wrong. Where is session?"); } Task <Profile> taskAwaiter = null; TaskScheduler taskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); // try get profile from cache var profile = _getNewProfileFunc(__instance, data); if (profile == null) { // load from server Debug.LogError("EmuTarkov.SinglePlayer: Loading bot profile from server"); List <WaveInfo> source = data.PrepareToLoadBackend(1).ToList(); taskAwaiter = session.LoadBots(source) .ContinueWith(GetFirstResult, taskScheduler); } else { // return cached profile Debug.LogError("EmuTarkov.SinglePlayer: Loading bot profile from cache"); taskAwaiter = Task.FromResult(profile); } // load bundles for bot profile var continuation = new Continuation(taskScheduler); __result = taskAwaiter .ContinueWith(continuation.LoadBundles, taskScheduler) .Unwrap(); return(false); }
public GClass560(Vector <GClass292> vector_1 = null, GClass292 gclass292_3 = null, GClass292 gclass292_4 = null, GClass292 gclass292_5 = null, GClass499 gclass499_1 = null) { Class13.lOBHd9Nzn7x2T(); base..ctor(); if (gclass292_4 == null) { this.gclass292_0 = new GClass292(0, 0); } else { this.gclass292_0 = gclass292_4; } if (vector_1 == null) { this.vector_0 = new Vector <GClass292>(); } else { this.vector_0 = vector_1; } if (gclass499_1 == null) { this.gclass499_0 = new GClass499(0); } else { this.gclass499_0 = gclass499_1; } if (gclass292_5 == null) { this.gclass292_1 = new GClass292(0, 0); } else { this.gclass292_1 = gclass292_5; } if (gclass292_3 == null) { this.gclass292_2 = new GClass292(0, 0); return; } this.gclass292_2 = gclass292_3; }
public virtual void imethod_1(BinaryStream binaryStream_0) { this.gclass292_0 = (GClass292)GClass86.smethod_2((int)binaryStream_0.smethod_1()); if (this.gclass292_0 != null) { this.gclass292_0.imethod_1(binaryStream_0); } while (this.vector_0.Length > 0) { this.vector_0.method_1(); } int i = 0; int num = binaryStream_0.ReadByte(); while (i < num) { GClass292 gclass = (GClass292)GClass86.smethod_2((int)binaryStream_0.smethod_1()); gclass.imethod_1(binaryStream_0); this.vector_0.method_0(gclass); i++; } this.gclass499_0 = (GClass499)GClass86.smethod_2((int)binaryStream_0.smethod_1()); if (this.gclass499_0 != null) { this.gclass499_0.imethod_1(binaryStream_0); } this.gclass292_1 = (GClass292)GClass86.smethod_2((int)binaryStream_0.smethod_1()); if (this.gclass292_1 != null) { this.gclass292_1.imethod_1(binaryStream_0); } this.gclass292_2 = (GClass292)GClass86.smethod_2((int)binaryStream_0.smethod_1()); if (this.gclass292_2 != null) { this.gclass292_2.imethod_1(binaryStream_0); } }