internal static void OnChangeIPTrigger2(SAChangeIP __instance, string __state) { var comp = ComputerLookup.Find(__instance.TargetComp); if (comp != null && comp.ip != __state) { ComputerLookup.NotifyIPChange(__state, comp.ip); } }
internal static void OnISPChangeIP(ILContext il) { ILCursor c = new ILCursor(il); c.GotoNext(MoveType.After, x => x.MatchCallOrCallvirt(AccessTools.Method(typeof(NetworkMap), nameof(NetworkMap.generateRandomIP)))); c.Emit(OpCodes.Dup); c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(ISPDaemon), nameof(ISPDaemon.scannedComputer))); c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(Computer), nameof(Computer.ip))); c.EmitDelegate <Action <string, string> >((newIp, oldIp) => { if (ComputerLookup.FindByIp(newIp) == null) { ComputerLookup.NotifyIPChange(oldIp, newIp); } }); }