示例#1
0
 public static void addLight(int i, int j, float R, float G, float B)
 {
     if (Main.netMode == 2)
     {
         return;
     }
     if (i - Lighting.firstTileX + Lighting.offScreenTiles >= 0 && i - Lighting.firstTileX + Lighting.offScreenTiles < Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10 && j - Lighting.firstTileY + Lighting.offScreenTiles >= 0 && j - Lighting.firstTileY + Lighting.offScreenTiles < Main.screenHeight / 16 + Lighting.offScreenTiles * 2 + 10)
     {
         if (Lighting.tempLights.Count == Lighting.maxTempLights)
         {
             return;
         }
         Point16 key = new Point16(i, j);
         Lighting.ColorTriplet value;
         if (Lighting.tempLights.TryGetValue(key, out value))
         {
             if (Lighting.RGB)
             {
                 if (value.r < R)
                 {
                     value.r = R;
                 }
                 if (value.g < G)
                 {
                     value.g = G;
                 }
                 if (value.b < B)
                 {
                     value.b = B;
                 }
                 Lighting.tempLights[key] = value;
                 return;
             }
             float num = (R + G + B) / 3f;
             if (value.r < num)
             {
                 Lighting.tempLights[key] = new Lighting.ColorTriplet(num);
                 return;
             }
         }
         else
         {
             if (Lighting.RGB)
             {
                 value = new Lighting.ColorTriplet(R, G, B);
             }
             else
             {
                 value = new Lighting.ColorTriplet((R + G + B) / 3f);
             }
             Lighting.tempLights.Add(key, value);
         }
     }
 }
示例#2
0
		public static void addLight(int i, int j, float R, float G, float B)
		{
			if (Main.netMode == 2)
			{
				return;
			}
			if (i - Lighting.firstTileX + Lighting.offScreenTiles >= 0 && i - Lighting.firstTileX + Lighting.offScreenTiles < Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10 && j - Lighting.firstTileY + Lighting.offScreenTiles >= 0 && j - Lighting.firstTileY + Lighting.offScreenTiles < Main.screenHeight / 16 + Lighting.offScreenTiles * 2 + 10)
			{
				if (Lighting.tempLights.Count == Lighting.maxTempLights)
				{
					return;
				}
				Point16 key = new Point16(i, j);
				Lighting.ColorTriplet value;
				if (Lighting.tempLights.TryGetValue(key, out value))
				{
					if (Lighting.RGB)
					{
						if (value.r < R)
						{
							value.r = R;
						}
						if (value.g < G)
						{
							value.g = G;
						}
						if (value.b < B)
						{
							value.b = B;
						}
						Lighting.tempLights[key] = value;
						return;
					}
					float num = (R + G + B) / 3f;
					if (value.r < num)
					{
						Lighting.tempLights[key] = new Lighting.ColorTriplet(num);
						return;
					}
				}
				else
				{
					if (Lighting.RGB)
					{
						value = new Lighting.ColorTriplet(R, G, B);
					}
					else
					{
						value = new Lighting.ColorTriplet((R + G + B) / 3f);
					}
					Lighting.tempLights.Add(key, value);
				}
			}
		}