private static void AllowColorChange(ILContext il) { ILCursor cursor = new ILCursor(il); while (cursor.TryGotoNext(MoveType.After, instr => instr.MatchCall <Color>("get_White"))) { cursor.Emit(OpCodes.Pop); cursor.Emit(OpCodes.Ldarg_0); // this cursor.EmitDelegate <Func <Component, Color> >((Component self) => { if (self.Entity.Get <DecalRainbowifier>() != null) { return(ColorHelper.GetHue(self.Scene, self.Entity.Position)); } else { return(Color.White); } }); return; } }