using System;
using OpenTK;
using OpenTK.Graphics;

namespace SharpQuake
{
	internal static class view
	{
		public static float Crosshair
		{
			get
			{
				return view._Crosshair.Value;
			}
		}

		public static float Gamma
		{
			get
			{
				return view._Gamma.Value;
			}
		}

		public static void Init()
		{
			cmd.Add("v_cshift", new xcommand_t(view.CShift_f));
			cmd.Add("bf", new xcommand_t(view.BonusFlash_f));
			cmd.Add("centerview", new xcommand_t(view.StartPitchDrift));
			if (view._LcdX == null)
			{
				view._LcdX = new cvar("lcd_x", "0");
				view._LcdYaw = new cvar("lcd_yaw", "0");
				view._ScrOfsX = new cvar("scr_ofsx", "0", false);
				view._ScrOfsY = new cvar("scr_ofsy", "0", false);
				view._ScrOfsZ = new cvar("scr_ofsz", "0", false);
				view._ClRollSpeed = new cvar("cl_rollspeed", "200");
				view._ClRollAngle = new cvar("cl_rollangle", "2.0");
				view._ClBob = new cvar("cl_bob", "0.02", false);
				view._ClBobCycle = new cvar("cl_bobcycle", "0.6", false);
				view._ClBobUp = new cvar("cl_bobup", "0.5", false);
				view._KickTime = new cvar("v_kicktime", "0.5", false);
				view._KickRoll = new cvar("v_kickroll", "0.6", false);
				view._KickPitch = new cvar("v_kickpitch", "0.6", false);
				view._IYawCycle = new cvar("v_iyaw_cycle", "2", false);
				view._IRollCycle = new cvar("v_iroll_cycle", "0.5", false);
				view._IPitchCycle = new cvar("v_ipitch_cycle", "1", false);
				view._IYawLevel = new cvar("v_iyaw_level", "0.3", false);
				view._IRollLevel = new cvar("v_iroll_level", "0.1", false);
				view._IPitchLevel = new cvar("v_ipitch_level", "0.3", false);
				view._IdleScale = new cvar("v_idlescale", "0", false);
				view._Crosshair = new cvar("crosshair", "0", true);
				view._ClCrossX = new cvar("cl_crossx", "0", false);
				view._ClCrossY = new cvar("cl_crossy", "0", false);
				view._glCShiftPercent = new cvar("gl_cshiftpercent", "100", false);
				view._CenterMove = new cvar("v_centermove", "0.15", false);
				view._CenterSpeed = new cvar("v_centerspeed", "500");
				view.BuildGammaTable(1f);
				view._Gamma = new cvar("gamma", "1", true);
			}
		}

		public static void RenderView()
		{
			if (Con.ForcedUp)
			{
				return;
			}
			if (client.cl.maxclients > 1)
			{
				cvar.Set("scr_ofsx", "0");
				cvar.Set("scr_ofsy", "0");
				cvar.Set("scr_ofsz", "0");
			}
			if (client.cl.intermission > 0)
			{
				view.CalcIntermissionRefDef();
			}
			else if (!client.cl.paused)
			{
				view.CalcRefDef();
			}
			render.PushDlights();
			if (view._LcdX.Value != 0f)
			{
				viddef_t vid = Scr.vid;
				refdef_t refDef = render.RefDef;
				vid.rowbytes <<= 1;
				vid.aspect *= 0.5f;
				refdef_t refdef_t = refDef;
				refdef_t.viewangles.Y = refdef_t.viewangles.Y - view._LcdYaw.Value;
				refDef.vieworg -= view._Right * view._LcdX.Value;
				render.RenderView();
				render.PushDlights();
				refdef_t refdef_t2 = refDef;
				refdef_t2.viewangles.Y = refdef_t2.viewangles.Y + view._LcdYaw.Value * 2f;
				refDef.vieworg += view._Right * view._LcdX.Value * 2f;
				render.RenderView();
				refdef_t refdef_t3 = refDef;
				refdef_t3.vrect.height = refdef_t3.vrect.height << 1;
				vid.rowbytes >>= 1;
				vid.aspect *= 2f;
				return;
			}
			render.RenderView();
		}

		public static float CalcRoll(ref Vector3 angles, ref Vector3 velocity)
		{
			mathlib.AngleVectors(ref angles, out view._Forward, out view._Right, out view._Up);
			float num = Vector3.Dot(velocity, view._Right);
			float num2 = (float)((num < 0f) ? -1 : 1);
			num = Math.Abs(num);
			float value = view._ClRollAngle.Value;
			if (num < view._ClRollSpeed.Value)
			{
				num = num * value / view._ClRollSpeed.Value;
			}
			else
			{
				num = value;
			}
			return num * num2;
		}

		public static void UpdatePalette()
		{
			view.CalcPowerupCshift();
			bool flag = false;
			client_state_t cl = client.cl;
			for (int i = 0; i < 4; i++)
			{
				if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
				{
					flag = true;
					cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
				}
				for (int j = 0; j < 3; j++)
				{
					if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
					{
						flag = true;
						cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
					}
				}
			}
			cl.cshifts[1].percent -= (int)(host.FrameTime * 150.0);
			if (cl.cshifts[1].percent < 0)
			{
				cl.cshifts[1].percent = 0;
			}
			cl.cshifts[2].percent -= (int)(host.FrameTime * 100.0);
			if (cl.cshifts[2].percent < 0)
			{
				cl.cshifts[2].percent = 0;
			}
			bool flag2 = view.CheckGamma();
			if (!flag && !flag2)
			{
				return;
			}
			view.CalcBlend();
			float num = view.Blend.A;
			float num2 = 255f * view.Blend.R * num;
			float num3 = 255f * view.Blend.G * num;
			float num4 = 255f * view.Blend.B * num;
			num = 1f - num;
			for (int k = 0; k < 256; k++)
			{
				int num5 = (int)((float)k * num + num2);
				int num6 = (int)((float)k * num + num3);
				int num7 = (int)((float)k * num + num4);
				if (num5 > 255)
				{
					num5 = 255;
				}
				if (num6 > 255)
				{
					num6 = 255;
				}
				if (num7 > 255)
				{
					num7 = 255;
				}
				view._Ramps[0, k] = view._GammaTable[num5];
				view._Ramps[1, k] = view._GammaTable[num6];
				view._Ramps[2, k] = view._GammaTable[num7];
			}
			byte[] basePal = host.BasePal;
			int num8 = 0;
			byte[] array = new byte[768];
			for (int l = 0; l < 256; l++)
			{
				int num9 = (int)basePal[num8];
				int num10 = (int)basePal[num8 + 1];
				int num11 = (int)basePal[num8 + 2];
				array[num8] = view._Ramps[0, num9];
				array[num8 + 1] = view._Ramps[1, num10];
				array[num8 + 2] = view._Ramps[2, num11];
				num8 += 3;
			}
			view.ShiftPalette(array);
		}

		public static void StartPitchDrift()
		{
			client_state_t cl = client.cl;
			if (cl.laststop == cl.time)
			{
				return;
			}
			if (cl.nodrift || cl.pitchvel == 0f)
			{
				cl.pitchvel = view._CenterSpeed.Value;
				cl.nodrift = false;
				cl.driftmove = 0f;
			}
		}

		public static void StopPitchDrift()
		{
			client_state_t cl = client.cl;
			cl.laststop = cl.time;
			cl.nodrift = true;
			cl.pitchvel = 0f;
		}

		public static void CalcBlend()
		{
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			cshift_t[] cshifts = client.cl.cshifts;
			if (view._glCShiftPercent.Value != 0f)
			{
				for (int i = 0; i < 4; i++)
				{
					float num5 = (float)cshifts[i].percent * view._glCShiftPercent.Value / 100f / 255f;
					if (num5 != 0f)
					{
						num4 += num5 * (1f - num4);
						num5 /= num4;
						num = num * (1f - num5) + (float)cshifts[i].destcolor[0] * num5;
						num2 = num2 * (1f - num5) + (float)cshifts[i].destcolor[1] * num5;
						num3 = num3 * (1f - num5) + (float)cshifts[i].destcolor[2] * num5;
					}
				}
			}
			view.Blend.R = num / 255f;
			view.Blend.G = num2 / 255f;
			view.Blend.B = num3 / 255f;
			view.Blend.A = num4;
			if (view.Blend.A > 1f)
			{
				view.Blend.A = 1f;
			}
			if (view.Blend.A < 0f)
			{
				view.Blend.A = 0f;
			}
		}

		public static void ParseDamage()
		{
			int num = net.Reader.ReadByte();
			int num2 = net.Reader.ReadByte();
			Vector3 left = net.Reader.ReadCoords();
			float num3 = (float)num2 * 0.5f + (float)num * 0.5f;
			if (num3 < 10f)
			{
				num3 = 10f;
			}
			client_state_t cl = client.cl;
			cl.faceanimtime = (float)cl.time + 0.2f;
			cl.cshifts[1].percent += (int)(3f * num3);
			if (cl.cshifts[1].percent < 0)
			{
				cl.cshifts[1].percent = 0;
			}
			if (cl.cshifts[1].percent > 150)
			{
				cl.cshifts[1].percent = 150;
			}
			if (num > num2)
			{
				cl.cshifts[1].destcolor[0] = 200;
				cl.cshifts[1].destcolor[1] = 100;
				cl.cshifts[1].destcolor[2] = 100;
			}
			else if (num != 0)
			{
				cl.cshifts[1].destcolor[0] = 220;
				cl.cshifts[1].destcolor[1] = 50;
				cl.cshifts[1].destcolor[2] = 50;
			}
			else
			{
				cl.cshifts[1].destcolor[0] = 255;
				cl.cshifts[1].destcolor[1] = 0;
				cl.cshifts[1].destcolor[2] = 0;
			}
			entity_t entity_t = client.Entities[cl.viewentity];
			left -= entity_t.origin;
			mathlib.Normalize(ref left);
			Vector3 right;
			Vector3 right2;
			Vector3 vector;
			mathlib.AngleVectors(ref entity_t.angles, out right, out right2, out vector);
			float num4 = Vector3.Dot(left, right2);
			view._DmgRoll = num3 * num4 * view._KickRoll.Value;
			num4 = Vector3.Dot(left, right);
			view._DmgPitch = num3 * num4 * view._KickPitch.Value;
			view._DmgTime = view._KickTime.Value;
		}

		public static void SetContentsColor(int contents)
		{
			switch (contents)
			{
			case -5:
				client.cl.cshifts[0] = view._CShift_lava;
				return;
			case -4:
				client.cl.cshifts[0] = view._CShift_slime;
				return;
			case -2:
			case -1:
				client.cl.cshifts[0] = view._CShift_empty;
				return;
			}
			client.cl.cshifts[0] = view._CShift_water;
		}

		private static void BuildGammaTable(float g)
		{
			if (g == 1f)
			{
				for (int i = 0; i < 256; i++)
				{
					view._GammaTable[i] = (byte)i;
				}
				return;
			}
			for (int j = 0; j < 256; j++)
			{
				int num = (int)(255.0 * Math.Pow(((double)j + 0.5) / 255.5, (double)g) + 0.5);
				if (num < 0)
				{
					num = 0;
				}
				if (num > 255)
				{
					num = 255;
				}
				view._GammaTable[j] = (byte)num;
			}
		}

		private static void CShift_f()
		{
			int.TryParse(cmd.Argv(1), out view._CShift_empty.destcolor[0]);
			int.TryParse(cmd.Argv(2), out view._CShift_empty.destcolor[1]);
			int.TryParse(cmd.Argv(3), out view._CShift_empty.destcolor[2]);
			int.TryParse(cmd.Argv(4), out view._CShift_empty.percent);
		}

		private static void BonusFlash_f()
		{
			client_state_t cl = client.cl;
			cl.cshifts[2].destcolor[0] = 215;
			cl.cshifts[2].destcolor[1] = 186;
			cl.cshifts[2].destcolor[2] = 69;
			cl.cshifts[2].percent = 50;
		}

		private static void CalcIntermissionRefDef()
		{
			entity_t viewEntity = client.ViewEntity;
			entity_t viewEnt = client.ViewEnt;
			refdef_t refDef = render.RefDef;
			refDef.vieworg = viewEntity.origin;
			refDef.viewangles = viewEntity.angles;
			viewEnt.model = null;
			view.AddIdle(1f);
		}

		private static void CalcRefDef()
		{
			view.DriftPitch();
			entity_t viewEntity = client.ViewEntity;
			entity_t viewEnt = client.ViewEnt;
			viewEntity.angles.Y = client.cl.viewangles.Y;
			viewEntity.angles.X = -client.cl.viewangles.X;
			float num = view.CalcBob();
			refdef_t refDef = render.RefDef;
			client_state_t cl = client.cl;
			refDef.vieworg = viewEntity.origin;
			refdef_t refdef_t = refDef;
			refdef_t.vieworg.Z = refdef_t.vieworg.Z + (cl.viewheight + num);
			refDef.vieworg += view.SmallOffset;
			refDef.viewangles = cl.viewangles;
			view.CalcViewRoll();
			view.AddIdle(view._IdleScale.Value);
			Vector3 angles = viewEntity.angles;
			angles.X = -angles.X;
			Vector3 vec;
			Vector3 vec2;
			Vector3 vec3;
			mathlib.AngleVectors(ref angles, out vec, out vec2, out vec3);
			refDef.vieworg += vec * view._ScrOfsX.Value + vec2 * view._ScrOfsY.Value + vec3 * view._ScrOfsZ.Value;
			view.BoundOffsets();
			viewEnt.angles = cl.viewangles;
			view.CalcGunAngle();
			viewEnt.origin = viewEntity.origin;
			entity_t entity_t = viewEnt;
			entity_t.origin.Z = entity_t.origin.Z + cl.viewheight;
			viewEnt.origin += vec * num * 0.4f;
			entity_t entity_t2 = viewEnt;
			entity_t2.origin.Z = entity_t2.origin.Z + num;
			float value = Scr.ViewSize.Value;
			if (value == 110f)
			{
				entity_t entity_t3 = viewEnt;
				entity_t3.origin.Z = entity_t3.origin.Z + 1f;
			}
			else if (value == 100f)
			{
				entity_t entity_t4 = viewEnt;
				entity_t4.origin.Z = entity_t4.origin.Z + 2f;
			}
			else if (value == 90f)
			{
				entity_t entity_t5 = viewEnt;
				entity_t5.origin.Z = entity_t5.origin.Z + 1f;
			}
			else if (value == 80f)
			{
				entity_t entity_t6 = viewEnt;
				entity_t6.origin.Z = entity_t6.origin.Z + 0.5f;
			}
			viewEnt.model = cl.model_precache[cl.stats[QStats.STAT_WEAPON]];
			viewEnt.frame = cl.stats[QStats.STAT_WEAPONFRAME];
			viewEnt.colormap = Scr.vid.colormap;
			refDef.viewangles += cl.punchangle;
			if (cl.onground && viewEntity.origin.Z - view._OldZ > 0f)
			{
				float num2 = (float)(cl.time - cl.oldtime);
				if (num2 < 0f)
				{
					num2 = 0f;
				}
				view._OldZ += num2 * 80f;
				if (view._OldZ > viewEntity.origin.Z)
				{
					view._OldZ = viewEntity.origin.Z;
				}
				if (viewEntity.origin.Z - view._OldZ > 12f)
				{
					view._OldZ = viewEntity.origin.Z - 12f;
				}
				refdef_t refdef_t2 = refDef;
				refdef_t2.vieworg.Z = refdef_t2.vieworg.Z + (view._OldZ - viewEntity.origin.Z);
				entity_t entity_t7 = viewEnt;
				entity_t7.origin.Z = entity_t7.origin.Z + (view._OldZ - viewEntity.origin.Z);
			}
			else
			{
				view._OldZ = viewEntity.origin.Z;
			}
			if (chase.IsActive)
			{
				chase.Update();
			}
		}

		private static void AddIdle(float idleScale)
		{
			double time = client.cl.time;
			Vector3 vec = new Vector3((float)(Math.Sin(time * (double)view._IPitchCycle.Value) * (double)view._IPitchLevel.Value), (float)(Math.Sin(time * (double)view._IYawCycle.Value) * (double)view._IYawLevel.Value), (float)(Math.Sin(time * (double)view._IRollCycle.Value) * (double)view._IRollLevel.Value));
			render.RefDef.viewangles += vec * idleScale;
		}

		private static void DriftPitch()
		{
			client_state_t cl = client.cl;
			if (host.NoClipAngleHack || !cl.onground || client.cls.demoplayback)
			{
				cl.driftmove = 0f;
				cl.pitchvel = 0f;
				return;
			}
			if (cl.nodrift)
			{
				if (Math.Abs(cl.cmd.forwardmove) < client.ForwardSpeed)
				{
					cl.driftmove = 0f;
				}
				else
				{
					cl.driftmove += (float)host.FrameTime;
				}
				if (cl.driftmove > view._CenterMove.Value)
				{
					view.StartPitchDrift();
				}
				return;
			}
			float num = cl.idealpitch - cl.viewangles.X;
			if (num == 0f)
			{
				cl.pitchvel = 0f;
				return;
			}
			float num2 = (float)host.FrameTime * cl.pitchvel;
			cl.pitchvel += (float)host.FrameTime * view._CenterSpeed.Value;
			if (num > 0f)
			{
				if (num2 > num)
				{
					cl.pitchvel = 0f;
					num2 = num;
				}
				client_state_t client_state_t = cl;
				client_state_t.viewangles.X = client_state_t.viewangles.X + num2;
				return;
			}
			if (num < 0f)
			{
				if (num2 > -num)
				{
					cl.pitchvel = 0f;
					num2 = -num;
				}
				client_state_t client_state_t2 = cl;
				client_state_t2.viewangles.X = client_state_t2.viewangles.X - num2;
			}
		}

		private static float CalcBob()
		{
			client_state_t cl = client.cl;
			float value = view._ClBobCycle.Value;
			float value2 = view._ClBobUp.Value;
			float num = (float)(cl.time - (double)((float)((int)(cl.time / (double)value)) * value));
			num /= value;
			if (num < value2)
			{
				num = 3.14159274f * num / value2;
			}
			else
			{
				num = (float)(3.1415926535897931 + 3.1415926535897931 * (double)(num - value2) / (1.0 - (double)value2));
			}
			double num2 = (double)(cl.velocity.Xy.Length * view._ClBob.Value);
			num2 = num2 * 0.3 + num2 * 0.7 * Math.Sin((double)num);
			if (num2 > 4.0)
			{
				num2 = 4.0;
			}
			else if (num2 < -7.0)
			{
				num2 = -7.0;
			}
			return (float)num2;
		}

		private static void CalcViewRoll()
		{
			client_state_t cl = client.cl;
			refdef_t refDef = render.RefDef;
			float num = view.CalcRoll(ref client.ViewEntity.angles, ref cl.velocity);
			refdef_t refdef_t = refDef;
			refdef_t.viewangles.Z = refdef_t.viewangles.Z + num;
			if (view._DmgTime > 0f)
			{
				refdef_t refdef_t2 = refDef;
				refdef_t2.viewangles.Z = refdef_t2.viewangles.Z + view._DmgTime / view._KickTime.Value * view._DmgRoll;
				refdef_t refdef_t3 = refDef;
				refdef_t3.viewangles.X = refdef_t3.viewangles.X + view._DmgTime / view._KickTime.Value * view._DmgPitch;
				view._DmgTime -= (float)host.FrameTime;
			}
			if (cl.stats[QStats.STAT_HEALTH] <= 0)
			{
				refDef.viewangles.Z = 80f;
				return;
			}
		}

		private static void BoundOffsets()
		{
			entity_t viewEntity = client.ViewEntity;
			refdef_t refDef = render.RefDef;
			if (refDef.vieworg.X < viewEntity.origin.X - 14f)
			{
				refDef.vieworg.X = viewEntity.origin.X - 14f;
			}
			else if (refDef.vieworg.X > viewEntity.origin.X + 14f)
			{
				refDef.vieworg.X = viewEntity.origin.X + 14f;
			}
			if (refDef.vieworg.Y < viewEntity.origin.Y - 14f)
			{
				refDef.vieworg.Y = viewEntity.origin.Y - 14f;
			}
			else if (refDef.vieworg.Y > viewEntity.origin.Y + 14f)
			{
				refDef.vieworg.Y = viewEntity.origin.Y + 14f;
			}
			if (refDef.vieworg.Z < viewEntity.origin.Z - 22f)
			{
				refDef.vieworg.Z = viewEntity.origin.Z - 22f;
				return;
			}
			if (refDef.vieworg.Z > viewEntity.origin.Z + 30f)
			{
				refDef.vieworg.Z = viewEntity.origin.Z + 30f;
			}
		}

		private static void CalcGunAngle()
		{
			refdef_t refDef = render.RefDef;
			float num = refDef.viewangles.Y;
			float num2 = -refDef.viewangles.X;
			num = view.AngleDelta(num - refDef.viewangles.Y) * 0.4f;
			if (num > 10f)
			{
				num = 10f;
			}
			if (num < -10f)
			{
				num = -10f;
			}
			num2 = view.AngleDelta(-num2 - refDef.viewangles.X) * 0.4f;
			if (num2 > 10f)
			{
				num2 = 10f;
			}
			if (num2 < -10f)
			{
				num2 = -10f;
			}
			float num3 = (float)host.FrameTime * 20f;
			if (num > view._OldYaw)
			{
				if (view._OldYaw + num3 < num)
				{
					num = view._OldYaw + num3;
				}
			}
			else if (view._OldYaw - num3 > num)
			{
				num = view._OldYaw - num3;
			}
			if (num2 > view._OldPitch)
			{
				if (view._OldPitch + num3 < num2)
				{
					num2 = view._OldPitch + num3;
				}
			}
			else if (view._OldPitch - num3 > num2)
			{
				num2 = view._OldPitch - num3;
			}
			view._OldYaw = num;
			view._OldPitch = num2;
			client_state_t cl = client.cl;
			cl.viewent.angles.Y = refDef.viewangles.Y + num;
			cl.viewent.angles.X = -(refDef.viewangles.X + num2);
			float value = view._IdleScale.Value;
			entity_t viewent = cl.viewent;
			viewent.angles.Z = viewent.angles.Z - (float)((double)value * Math.Sin(cl.time * (double)view._IRollCycle.Value) * (double)view._IRollLevel.Value);
			entity_t viewent2 = cl.viewent;
			viewent2.angles.X = viewent2.angles.X - (float)((double)value * Math.Sin(cl.time * (double)view._IPitchCycle.Value) * (double)view._IPitchLevel.Value);
			entity_t viewent3 = cl.viewent;
			viewent3.angles.Y = viewent3.angles.Y - (float)((double)value * Math.Sin(cl.time * (double)view._IYawCycle.Value) * (double)view._IYawLevel.Value);
		}

		private static float AngleDelta(float a)
		{
			a = mathlib.AngleMod((double)a);
			if (a > 180f)
			{
				a -= 360f;
			}
			return a;
		}

		private static void CalcPowerupCshift()
		{
			client_state_t cl = client.cl;
			if (cl.HasItems(QItems.IT_QUAD))
			{
				cl.cshifts[3].destcolor[0] = 0;
				cl.cshifts[3].destcolor[1] = 0;
				cl.cshifts[3].destcolor[2] = 255;
				cl.cshifts[3].percent = 30;
				return;
			}
			if (cl.HasItems(QItems.IT_SUIT))
			{
				cl.cshifts[3].destcolor[0] = 0;
				cl.cshifts[3].destcolor[1] = 255;
				cl.cshifts[3].destcolor[2] = 0;
				cl.cshifts[3].percent = 20;
				return;
			}
			if (cl.HasItems(QItems.IT_INVISIBILITY))
			{
				cl.cshifts[3].destcolor[0] = 100;
				cl.cshifts[3].destcolor[1] = 100;
				cl.cshifts[3].destcolor[2] = 100;
				cl.cshifts[3].percent = 100;
				return;
			}
			if (cl.HasItems(QItems.IT_INVULNERABILITY))
			{
				cl.cshifts[3].destcolor[0] = 255;
				cl.cshifts[3].destcolor[1] = 255;
				cl.cshifts[3].destcolor[2] = 0;
				cl.cshifts[3].percent = 30;
				return;
			}
			cl.cshifts[3].percent = 0;
		}

		private static bool CheckGamma()
		{
			if (view._Gamma.Value == view._OldGammaValue)
			{
				return false;
			}
			view._OldGammaValue = view._Gamma.Value;
			view.BuildGammaTable(view._Gamma.Value);
			Scr.vid.recalc_refdef = true;
			return true;
		}

		private static void ShiftPalette(byte[] palette)
		{
		}

		static view()
		{
			view._GammaTable = new byte[256];
			view._CShift_empty = new cshift_t(new int[]
			{
				130,
				80,
				50
			}, 0);
			view._CShift_water = new cshift_t(new int[]
			{
				130,
				80,
				50
			}, 128);
			view._CShift_slime = new cshift_t(new int[]
			{
				0,
				25,
				5
			}, 150);
			int[] array = new int[3];
			array[0] = 255;
			array[1] = 80;
			view._CShift_lava = new cshift_t(array, 150);
		}

		public static Color4 Blend;

		private static readonly Vector3 SmallOffset = Vector3.One / 32f;

		private static cvar _LcdX;

		private static cvar _LcdYaw;

		private static cvar _ScrOfsX;

		private static cvar _ScrOfsY;

		private static cvar _ScrOfsZ;

		private static cvar _ClRollSpeed;

		private static cvar _ClRollAngle;

		private static cvar _ClBob;

		private static cvar _ClBobCycle;

		private static cvar _ClBobUp;

		private static cvar _KickTime;

		private static cvar _KickRoll;

		private static cvar _KickPitch;

		private static cvar _IYawCycle;

		private static cvar _IRollCycle;

		private static cvar _IPitchCycle;

		private static cvar _IYawLevel;

		private static cvar _IRollLevel;

		private static cvar _IPitchLevel;

		private static cvar _IdleScale;

		private static cvar _Crosshair;

		private static cvar _ClCrossX;

		private static cvar _ClCrossY;

		private static cvar _glCShiftPercent;

		private static cvar _Gamma;

		private static cvar _CenterMove;

		private static cvar _CenterSpeed;

		private static byte[] _GammaTable;

		private static cshift_t _CShift_empty;

		private static cshift_t _CShift_water;

		private static cshift_t _CShift_slime;

		private static cshift_t _CShift_lava;

		private static byte[,] _Ramps = new byte[3, 256];

		private static Vector3 _Forward;

		private static Vector3 _Right;

		private static Vector3 _Up;

		private static float _DmgTime;

		private static float _DmgRoll;

		private static float _DmgPitch;

		private static float _OldZ = 0f;

		private static float _OldYaw = 0f;

		private static float _OldPitch = 0f;

		private static float _OldGammaValue;
	}
}
