Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ScreenObstruction.cs
Go to the documentation of this file.
1
using
Microsoft.Xna.Framework
;
2
using
Microsoft.Xna.Framework.Graphics
;
3
4
namespace
Terraria.GameContent.Events
;
5
6
public
class
ScreenObstruction
7
{
8
public
static
float
screenObstruction
;
9
10
public
static
void
Update
()
11
{
12
float
value = 0f;
13
float
amount = 0.1f;
14
if
(
Main
.
player
[
Main
.
myPlayer
].headcovered)
15
{
16
value = 0.95f;
17
amount = 0.3f;
18
}
19
screenObstruction
=
MathHelper
.
Lerp
(
screenObstruction
, value, amount);
20
}
21
22
public
static
void
Draw
(
SpriteBatch
spriteBatch)
23
{
24
if
(
screenObstruction
!= 0f)
25
{
26
Color
color = Color.Black *
screenObstruction
;
27
int
num =
TextureAssets
.
Extra
[49].Width();
28
int
num2 = 10;
29
Rectangle
rect =
Main
.
player
[
Main
.
myPlayer
].getRect();
30
rect.
Inflate
((num - rect.
Width
) / 2, (num - rect.
Height
) / 2 + num2 / 2);
31
rect.
Offset
(-(
int
)
Main
.
screenPosition
.X, -(
int
)
Main
.
screenPosition
.Y + (
int
)
Main
.
player
[
Main
.
myPlayer
].gfxOffY - num2);
32
Rectangle
destinationRectangle =
Rectangle
.
Union
(
new
Rectangle
(0, 0, 1, 1),
new
Rectangle
(rect.
Right
- 1, rect.
Top
- 1, 1, 1));
33
Rectangle
destinationRectangle2 =
Rectangle
.
Union
(
new
Rectangle
(
Main
.
screenWidth
- 1, 0, 1, 1),
new
Rectangle
(rect.
Right
, rect.
Bottom
- 1, 1, 1));
34
Rectangle
destinationRectangle3 =
Rectangle
.
Union
(
new
Rectangle
(
Main
.
screenWidth
- 1,
Main
.
screenHeight
- 1, 1, 1),
new
Rectangle
(rect.
Left
, rect.
Bottom
, 1, 1));
35
Rectangle
destinationRectangle4 =
Rectangle
.
Union
(
new
Rectangle
(0,
Main
.
screenHeight
- 1, 1, 1),
new
Rectangle
(rect.
Left
- 1, rect.
Top
, 1, 1));
36
spriteBatch.
Draw
(
TextureAssets
.
MagicPixel
.Value, destinationRectangle,
new
Rectangle
(0, 0, 1, 1), color);
37
spriteBatch.
Draw
(
TextureAssets
.
MagicPixel
.Value, destinationRectangle2,
new
Rectangle
(0, 0, 1, 1), color);
38
spriteBatch.
Draw
(
TextureAssets
.
MagicPixel
.Value, destinationRectangle3,
new
Rectangle
(0, 0, 1, 1), color);
39
spriteBatch.
Draw
(
TextureAssets
.
MagicPixel
.Value, destinationRectangle4,
new
Rectangle
(0, 0, 1, 1), color);
40
spriteBatch.
Draw
(
TextureAssets
.
Extra
[49].Value, rect, color);
41
}
42
}
43
}
Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw
void Draw(Texture2D texture, Vector2 position, Color color)
Definition
SpriteBatch.cs:397
Microsoft.Xna.Framework.Graphics.SpriteBatch
Definition
SpriteBatch.cs:8
Microsoft.Xna.Framework.MathHelper.Lerp
static float Lerp(float value1, float value2, float amount)
Definition
MathHelper.cs:53
Microsoft.Xna.Framework.MathHelper
Definition
MathHelper.cs:6
Terraria.GameContent.Events.ScreenObstruction.screenObstruction
static float screenObstruction
Definition
ScreenObstruction.cs:8
Terraria.GameContent.Events.ScreenObstruction.Draw
static void Draw(SpriteBatch spriteBatch)
Definition
ScreenObstruction.cs:22
Terraria.GameContent.Events.ScreenObstruction.Update
static void Update()
Definition
ScreenObstruction.cs:10
Terraria.GameContent.Events.ScreenObstruction
Definition
ScreenObstruction.cs:7
Terraria.GameContent.TextureAssets.Extra
static Asset< Texture2D >[] Extra
Definition
TextureAssets.cs:368
Terraria.GameContent.TextureAssets.MagicPixel
static Asset< Texture2D > MagicPixel
Definition
TextureAssets.cs:84
Terraria.GameContent.TextureAssets
Definition
TextureAssets.cs:8
Terraria.Main.myPlayer
static int myPlayer
Definition
Main.cs:1801
Terraria.Main.screenHeight
static int screenHeight
Definition
Main.cs:1721
Terraria.Main.screenPosition
static Vector2 screenPosition
Definition
Main.cs:1715
Terraria.Main.screenWidth
static int screenWidth
Definition
Main.cs:1719
Terraria.Main.player
static Player[] player
Definition
Main.cs:1803
Terraria.Main
Definition
Main.cs:79
Microsoft.Xna.Framework.Graphics
Definition
AlphaTestEffect.cs:1
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
Terraria.GameContent.Events
Definition
BirthdayParty.cs:9
Microsoft.Xna.Framework.Color
Definition
Color.cs:12
Microsoft.Xna.Framework.Rectangle.Inflate
void Inflate(int horizontalAmount, int verticalAmount)
Definition
Rectangle.cs:84
Microsoft.Xna.Framework.Rectangle.Height
int Height
Definition
Rectangle.cs:23
Microsoft.Xna.Framework.Rectangle.Right
int Right
Definition
Rectangle.cs:29
Microsoft.Xna.Framework.Rectangle.Left
int Left
Definition
Rectangle.cs:27
Microsoft.Xna.Framework.Rectangle.Bottom
int Bottom
Definition
Rectangle.cs:33
Microsoft.Xna.Framework.Rectangle.Union
static Rectangle Union(Rectangle value1, Rectangle value2)
Definition
Rectangle.cs:197
Microsoft.Xna.Framework.Rectangle.Width
int Width
Definition
Rectangle.cs:20
Microsoft.Xna.Framework.Rectangle.Offset
void Offset(Point amount)
Definition
Rectangle.cs:72
Microsoft.Xna.Framework.Rectangle.Top
int Top
Definition
Rectangle.cs:31
Microsoft.Xna.Framework.Rectangle
Definition
Rectangle.cs:12
source
Terraria.GameContent.Events
ScreenObstruction.cs
Generated by
1.10.0