Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddLight()

void Terraria.Graphics.Light.LegacyLighting.AddLight ( int x,
int y,
Vector3 color )
inline

Implements Terraria.Graphics.Light.ILightingEngine.

Definition at line 251 of file LegacyLighting.cs.

252 {
253 float x2 = color.X;
254 float y2 = color.Y;
255 float z = color.Z;
256 if (x - _requestedRectLeft + Lighting.OffScreenTiles < 0 || !((float)(x - _requestedRectLeft + Lighting.OffScreenTiles) < _camera.UnscaledSize.X / 16f + (float)(Lighting.OffScreenTiles * 2) + 10f) || y - _requestedRectTop + Lighting.OffScreenTiles < 0 || !((float)(y - _requestedRectTop + Lighting.OffScreenTiles) < _camera.UnscaledSize.Y / 16f + (float)(Lighting.OffScreenTiles * 2) + 10f) || _tempLights.Count == 2000)
257 {
258 return;
259 }
260 Point16 key = new Point16(x, y);
262 {
263 if (_rgb)
264 {
265 if (value.R < x2)
266 {
267 value.R = x2;
268 }
269 if (value.G < y2)
270 {
271 value.G = y2;
272 }
273 if (value.B < z)
274 {
275 value.B = z;
276 }
278 }
279 else
280 {
281 float num = (x2 + y2 + z) / 3f;
282 if (value.R < num)
283 {
284 _tempLights[key] = new ColorTriplet(num);
285 }
286 }
287 }
288 else
289 {
290 value = ((!_rgb) ? new ColorTriplet((x2 + y2 + z) / 3f) : new ColorTriplet(x2, y2, z));
292 }
293 }
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
Dictionary< Point16, ColorTriplet > _tempLights

References Terraria.Graphics.Light.LegacyLighting._camera, Terraria.Graphics.Light.LegacyLighting._requestedRectLeft, Terraria.Graphics.Light.LegacyLighting._requestedRectTop, Terraria.Graphics.Light.LegacyLighting._rgb, Terraria.Graphics.Light.LegacyLighting._tempLights, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.key, Terraria.Lighting.OffScreenTiles, System.Collections.Generic.Dictionary< TKey, TValue >.TryGetValue(), Terraria.Graphics.Camera.UnscaledSize, System.value, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector3.X, Microsoft.Xna.Framework.Vector2.Y, Microsoft.Xna.Framework.Vector3.Y, and Microsoft.Xna.Framework.Vector3.Z.