108 public override void Update(GameTime gameTime)
117 _progress += (float)gameTime.ElapsedGameTime.TotalSeconds * base.Intensity * 0.75f;
123 base.Update(gameTime);
108 public override void Update(GameTime gameTime) {
…}
137 graphicsDevice.
Clear(
new Color(0.5f, 0.5f, 0f, 1f));
142 graphicsDevice.
Clear(
new Color(0.5f, 0.5f, 0.5f, 1f));
163 destination.X -= vector.
X;
164 destination.Y -= vector.
Y;
166 destination.X += vector2.
X;
167 destination.Y += vector2.
Y;
190 for (
int i = 0; i < 200; i++)
197 Vector2 vector4 = nPC.Center - vector2;
200 num = num * 0.3f + 0.7f * num * (1024f / (float)(nPC.
height * nPC.
width));
202 num += (nPC.velocity - nPC.
oldVelocity).Length() * 0.5f;
206 vector4 -= velocity * 10f;
213 tileBatch.
Draw(
TextureAssets.
MagicPixel.Value,
new Vector4(vector4.
X, vector4.
Y, (
float)nPC.width * 2f, (float)nPC.
height * 2f) * 0.25f,
null,
new VertexColors(
new Color(vector5.
X * 0.5f + 0.5f, vector5.
Y * 0.5f + 0.5f, 0.5f * num)),
new Vector2((
float)
TextureAssets.
MagicPixel.Width() / 2f, (
float)
TextureAssets.
MagicPixel.Height() / 2f),
SpriteEffects.None, nPC.
rotation);
218 num = 0.195f * (float)
Math.
Sqrt(num);
230 for (
int j = 0; j < 255; j++)
237 Vector2 vector6 = player.Center - vector2;
239 num3 = 0.05f * (float)
Math.
Sqrt(num3);
242 vector6 -= velocity2 * 10f;
265 for (
int k = 0; k < 1000; k++)
274 bool flag = projectile.
lavaWet;
276 bool flag3 = projectile.
wet;
290 if (!(num5 || flag || flag2))
295 Vector2 vector7 = projectile.Center - vector2;
297 num6 = 2f * (float)
Math.
Sqrt(0.05f * num6);
304 float num7 =
Math.
Max(12f, (
float)projectile.width * 0.75f);
305 float num8 =
Math.
Max(12f, (
float)projectile.height * 0.75f);
319 tileBatch.
Draw(
value,
new Vector4(vector8.
X, vector8.
Y, size.X, size.Y) * 0.25f, sourceRectangle,
new VertexColors(
_rippleQueue[l].WaveData),
new Vector2(sourceRectangle.
Width / 2, sourceRectangle.
Height / 2),
SpriteEffects.None,
_rippleQueue[l].
Rotation);
350 graphicsDevice.
Clear(
new Color(0.5f, 0.5f, 0f, 1f));
376 int backBufferWidth =
Main.
instance.GraphicsDevice.PresentationParameters.BackBufferWidth;
377 int backBufferHeight =
Main.
instance.GraphicsDevice.PresentationParameters.BackBufferHeight;
397 width = (int)((
float)width * 0.25f);
398 height = (int)((
float)height * 0.25f);
410 Console.
WriteLine(
"Failed to create water distortion render targets. " + ex);
429 Console.
WriteLine(
"Error disposing of water distortion render targets. " + ex);
438 float g = strength * 0.5f + 0.5f;
445 float g = strength * 0.5f + 0.5f;
447 QueueRipple(position,
new Color(0.5f, g, 0f, 1f) * num, size, shape, rotation);
void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
unsafe void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
SamplerStateCollection SamplerStates
override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
static readonly SamplerState PointClamp
static float Clamp(float value, float min, float max)
static byte Min(byte val1, byte val2)
static double Sqrt(double d)
static double Abs(double value)
static double Floor(double d)
static byte Max(byte val1, byte val2)
static bool WetCollision(Vector2 Position, int Width, int Height)
static bool LavaCollision(Vector2 Position, int Width, int Height)
static bool CheckAABBvAABBCollision(Vector2 position1, Vector2 dimensions1, Vector2 position2, Vector2 dimensions2)
static LiquidRenderer Instance
override void Update(GameTime gameTime)
const float DISTORTION_BUFFER_SCALE
RenderTarget2D _distortionTargetSwap
Asset< Texture2D > _rippleShapeTexture
Texture2D[] _viscosityMaskChain
void QueueRipple(Vector2 position, float strength, Vector2 size, RippleShape shape=RippleShape.Square, float rotation=0f)
Action< TileBatch > OnWaveDraw
void PreDraw(GameTime gameTime)
void QueueRipple(Vector2 position, Color waveData, Vector2 size, RippleShape shape=RippleShape.Square, float rotation=0f)
const int MAX_RIPPLES_QUEUED
void ValidateRenderTargets()
void ReleaseRenderTargets()
const float WAVE_FRAMERATE
void InitRenderTargets(int width, int height)
void QueueRipple(Vector2 position, float strength=1f, RippleShape shape=RippleShape.Square, float rotation=0f)
WaterShaderData(string passName)
RenderTarget2D _distortionTarget
const int MAX_QUEUED_STEPS
Vector2 _lastDistortionDrawOffset
static Asset< Texture2D > MagicPixel
static Dictionary< string, MiscShaderData > Misc
ScreenShaderData UseProgress(float progress)
ScreenShaderData UseTargetPosition(Vector2 position)
ScreenShaderData UseImageOffset(Vector2 offset)
ScreenShaderData UseImage(Texture2D image, int index=0, SamplerState samplerState=null)
void Draw(Texture2D texture, Vector2 position, VertexColors colors)
void Begin(RasterizerState rasterizer, Matrix transformation)
static bool[] CanDistortWater
static bool[] NoLiquidDistortion
static Vector2 sceneWaterPos
static bool IsGraphicsDeviceAvailable
static Vector2 screenPosition
static SpriteViewMatrix GameViewMatrix
static int offScreenRange
static TileBatch tileBatch
static Projectile[] projectile
static RenderTarget2D waterTarget
static IAssetRepository Assets
static GraphicsDeviceManager graphics
readonly RippleShape Shape
Ripple(Vector2 position, Color waveData, Vector2 size, RippleShape shape, float rotation)
readonly Vector2 Position
static readonly Rectangle[] RIPPLE_SHAPE_SOURCE_RECTS
Rectangle SourceRectangle