Water animation improvements

* Added the ability for contentpacks to change the animation speed of water
* Water backdrops are synced to the current map's water animation speed
This commit is contained in:
JappaWakka 2022-04-16 18:19:27 +02:00
parent 249a93bc3f
commit ea0ab80ba6
5 changed files with 37 additions and 33 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -8,10 +8,12 @@
Dim WaterAnimation As Animation
Dim currentRectangle As New Rectangle(0, 0, 0, 0)
Public Shared Property WaterSpeed As Integer = 8
Public Overrides Sub Initialize()
MyBase.Initialize()
WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Routes"), 1, 3, 16, 16, 9, 15, 0)
WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Routes"), 1, 3, 16, 16, WaterSpeed, 15, 0)
CreateWaterTextureTemp()
End Sub
@ -161,7 +163,7 @@
Public Overrides Sub UpdateEntity()
If Not WaterAnimation Is Nothing Then
WaterAnimation.Update(0.01)
WaterAnimation.Update(0.005)
If currentRectangle <> WaterAnimation.TextureRectangle Then
ChangeTexture()

View File

@ -23,7 +23,7 @@
Dim tempRasterizer = GraphicsDevice.RasterizerState
GraphicsDevice.RasterizerState = RasterizerState.CullNone
GraphicsDevice.SamplerStates(0) = New SamplerState() With {.AddressU = TextureAddressMode.Wrap, .AddressV = TextureAddressMode.Wrap}
GraphicsDevice.SamplerStates(0) = New SamplerState() With {.Filter = TextureFilter.Point, .AddressU = TextureAddressMode.Wrap, .AddressV = TextureAddressMode.Wrap}
For Each b As Backdrop In Me._backdrops
b.Draw({0, 1, 3, 2, 3, 0})
@ -75,11 +75,12 @@
Private _position As Vector3
Private _rotation As Vector3
Private _shader As Effect
Private _width As Integer = 0
Private _height As Integer = 0
Private _waterAnimationDelay As Single = 1.0F
Dim WaterAnimation As Animation
Private _waterAnimationDelay As Single = CSng(1 / Water.WaterSpeed)
Private _waterAnimationIndex As Integer = 0
Private _setTexture As Boolean = False
@ -106,7 +107,8 @@
Select Case BackdropType.ToLower()
Case "water"
Me._backdropType = BackdropTypes.Water
_backdropTexture = TextureManager.GetTexture("Backdrops\Water", New Rectangle(0, 0, 64, 64))
WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Backdrops\Water"), 1, 3, 64, 64, Water.WaterSpeed, 0, 0)
_backdropTexture = TextureManager.GetTexture("Textures\Backdrops\Water", WaterAnimation.TextureRectangle, "")
Case "grass"
Me._backdropType = BackdropTypes.Grass
Case "texture"
@ -121,16 +123,11 @@
Select Case Me._backdropType
Case BackdropTypes.Water
_waterAnimationDelay -= 0.1F
If _waterAnimationDelay <= 0.0F Then
_waterAnimationDelay = 1.0F
_waterAnimationIndex += 1
If _waterAnimationIndex = 3 Then
_waterAnimationIndex = 0
If Core.GameOptions.GraphicStyle = 1 Then
If Not WaterAnimation Is Nothing Then
WaterAnimation.Update(0.005)
_backdropTexture = TextureManager.GetTexture("Textures\Backdrops\Water", WaterAnimation.TextureRectangle, "")
End If
_backdropTexture = TextureManager.GetTexture("Backdrops\Water", New Rectangle(64 * _waterAnimationIndex, 0, 64, 64))
End If
Case BackdropTypes.Grass
If Me._setTexture = False Then

View File

@ -9,6 +9,9 @@
If System.IO.File.Exists(ContentPackFile) = True Then
Dim Lines() As String = System.IO.File.ReadAllLines(ContentPackFile)
For Each Line As String In Lines
If Line.GetSplit(0, "|").ToLower = "waterspeed" Then
Water.WaterSpeed = CInt(Line.GetSplit(1, "|"))
Else
Select Case Line.CountSplits("|")
Case 2 'ResolutionChange
Dim TextureName As String = Line.GetSplit(0, "|")
@ -30,6 +33,7 @@
TextureReplacements.Add(oldTextureSource, newTextureSource)
End If
End Select
End If
Next
End If
End If

View File

@ -504,6 +504,7 @@
Core.GameOptions.SaveOptions()
MusicManager.PlayNoMusic()
ContentPackManager.Clear()
Water.WaterSpeed = 8
For Each s As String In Core.GameOptions.ContentPackNames
ContentPackManager.Load(GameController.GamePath & "\ContentPacks\" & s & "\exceptions.dat")
Next