/// <summary> /// Draws the optional "light sprite", just a simple sprite with no shadows /// </summary> /// <param name="spriteBatch"></param> public void DrawSprite(SpriteBatch spriteBatch, Camera cam) { if (DeformableLightSprite != null) { Vector2 origin = DeformableLightSprite.Origin; Vector2 drawPos = position; if (ParentSub != null) { drawPos += ParentSub.DrawPosition; } DeformableLightSprite.Draw( cam, new Vector3(drawPos, 0.0f), origin, -Rotation, SpriteScale, new Color(Color, lightSourceParams.OverrideLightSpriteAlpha ?? Color.A / 255.0f), LightSpriteEffect == SpriteEffects.FlipHorizontally); } if (LightSprite != null) { Vector2 origin = LightSprite.Origin; if (LightSpriteEffect == SpriteEffects.FlipHorizontally) { origin.X = LightSprite.SourceRect.Width - origin.X; } if (LightSpriteEffect == SpriteEffects.FlipVertically) { origin.Y = LightSprite.SourceRect.Height - origin.Y; } Vector2 drawPos = position; if (ParentSub != null) { drawPos += ParentSub.DrawPosition; } drawPos.Y = -drawPos.Y; LightSprite.Draw( spriteBatch, drawPos, new Color(Color, lightSourceParams.OverrideLightSpriteAlpha ?? Color.A / 255.0f), origin, -Rotation, SpriteScale, LightSpriteEffect); } }
/// <summary> /// Draws the optional "light sprite", just a simple sprite with no shadows /// </summary> /// <param name="spriteBatch"></param> public void DrawSprite(SpriteBatch spriteBatch, Camera cam) { if (DeformableLightSprite != null) { Vector2 origin = DeformableLightSprite.Origin; Vector2 drawPos = position; if (ParentSub != null) { drawPos += ParentSub.DrawPosition; } DeformableLightSprite.Draw( cam, new Vector3(drawPos, 0.0f), origin, -Rotation, SpriteScale, new Color(Color, lightSourceParams.OverrideLightSpriteAlpha ?? Color.A / 255.0f), LightSpriteEffect == SpriteEffects.FlipHorizontally); } if (LightSprite != null) { Vector2 origin = LightSprite.Origin; if (LightSpriteEffect == SpriteEffects.FlipHorizontally) { origin.X = LightSprite.SourceRect.Width - origin.X; } if (LightSpriteEffect == SpriteEffects.FlipVertically) { origin.Y = LightSprite.SourceRect.Height - origin.Y; } Vector2 drawPos = position; if (ParentSub != null) { drawPos += ParentSub.DrawPosition; } drawPos.Y = -drawPos.Y; LightSprite.Draw( spriteBatch, drawPos, new Color(Color, lightSourceParams.OverrideLightSpriteAlpha ?? Color.A / 255.0f), origin, -Rotation, SpriteScale, LightSpriteEffect); } if (GameMain.DebugDraw) { //visualize light recalculations float timeSinceRecalculation = (float)Timing.TotalTime - lastRecalculationTime; if (timeSinceRecalculation < 0.1f) { Vector2 drawPos = position; if (ParentSub != null) { drawPos += ParentSub.DrawPosition; } drawPos.Y = -drawPos.Y; GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, Color.Red * (1.0f - timeSinceRecalculation * 10.0f), isFilled: true); GUI.DrawLine(spriteBatch, drawPos - Vector2.One * Range, drawPos + Vector2.One * Range, Color); GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * Range, drawPos + new Vector2(1.0f, -1.0f) * Range, Color); } } }