From ea0ab80ba665474cf02e112fdbc4e491d43a37a7 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 16 Apr 2022 18:19:27 +0200 Subject: [PATCH] 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 --- P3D/Content/Textures/Backdrops/Water.png | Bin 3046 -> 1041 bytes P3D/Entites/Enviroment/Water.vb | 6 ++-- P3D/Overworld/BackdropRenderer.vb | 23 ++++++------- P3D/Resources/ContentPackManager.vb | 40 +++++++++++++---------- P3D/Screens/NewOptionScreen.vb | 1 + 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/P3D/Content/Textures/Backdrops/Water.png b/P3D/Content/Textures/Backdrops/Water.png index 21dd680794a113fd1ab788ee9b06baab63ba4cf6..d3d7b49c511d7c96787825a26601c35575b42a45 100644 GIT binary patch literal 1041 zcmeAS@N?(olHy`uVBq!ia0vp^2Y}dtgAGXfYWa7k%OX1+p5etyouP{Qm8ovMUp1j(1sA}geUE9SF(xk?H;Y8T-{IrbBqiQf^4i|sj zk~Ya+Xv}wp%Ub(IdbT9zgEeaxXK=z4fa#wOAMJ*Znf_qpiehLda`K7Bq_-ghJD`p?ZD`q*lecayn_=WPecGydS&n|w^Vb;eSs5J)Hxj6; z!I-Jw@2-E}WfllGcnCI!m#kjzf2}d=!g+=TL8m3_ZqA+tHM$^*LCN%>_v2R!Vk=`x z_vFZ~+GTGwYg+W2@H5vg%~FRsz`>wbRB-d^we6<+wnr?#bZy?&o+bN~8G81e=h0pJ zkrAe>iCK64sgUHQ8&+Muvf%u>#=TK)U)H>P_vY)_d0UWzMZqHD+dlQJ3dep&Fu3IO zzbTz-;Ql3~J7QCHhu;01g{m;)fb@Zzj2ns$-8;AYm3T+V7unw6o9FaryKj#>dZMgl z-Ib!0?U(eY&3iSoW!2{LJh(PTMkUL;S%p(gbDsRDPti|W{W|xCmu~ux)chzWn4*|3 zR%g~V^}U(hD8?}LWz^BIrPBl%l*DsN_A$=BXtXIm`h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23dn@<^39KZL8eu ztkHg83EO6DYR%;jxo23K8M+RgO(CBeb)-(stdu2F zwXPuJah{52jZ{jmB6o-kD2jmJNkGw)KiP z9OQbJA3jrPqJ=J4mfkS}PX1w@D#-k07Mn9zE~ALjG1@!xi-nbsZ9lDkGdE*c$;EC5 zu86w$`GPL{SOz5PHdmRxAIj*?-@FhEHo?xJx^07I=i>hG>Q~iCY3^Ubz)O2r;`}%i zM*FbhLuj8}R;)>pwvZYI)xk1{=N%{u&P3AOfnVgX6t;UPLp+NI^Jhn*hz8rk#;A&` z0mOOm15vuBjx=R7&Gq>S%`)Hemv?s-R${4KbnZIL2*c5e6FZB9@i{Di)~!GM%#pA> zNm9w0!|^)P63EhtKcV;lywaIg56CLvMd#@J3;+*g4xv|@4(glhCAtSL-=EvyA1g&4 zrPO2%g^4|bU59TFnl+;7u+x(-Ev75A*5yeKV)e;)@12ch7nJZdDe7o-rYK!RCpBD# zS|t1=L06G(+?GbY$iRzoO1!_6lxf;N`SilmzzLgw!E?m1M0p~QQ4J6Bm-`q@F*y!J zBRbcsV#UfT#?v(_VtmAp470&xY;F%;v%o7_Hsq7;LZLxGaYqrHohq}@b+2G`Gao&I9FIYBr^9EFg(KE4EWLAj z^~LakZ$|=x{~g&2;W6!ntvrT`|NBHS=kpd4RBf%(eck(U{3s3DXSxVmg(8U_WNO63 z9V}{7VPzJ^)OXJp-S)p)wLn6jf0nGl)klC$=mtGmK%GiGS`SnL_^|{q+WfVJfi|qX zk%uc1X3eAmc(HP@D;cu;96&R#6;>LC6G)Wq$+2>9jH$RT520*XxLltjI7J&fCY?-5 zm#8uamQma zn1Fu)gH4k~*Tw2#j&lD*3w%dTtOcHloX%|+L|SLpdSo}9!wCPrT)8Cn60O1gNY|t z-i$}w&FA&+-~ WaterAnimation.TextureRectangle Then ChangeTexture() diff --git a/P3D/Overworld/BackdropRenderer.vb b/P3D/Overworld/BackdropRenderer.vb index 4b944c503..54d274600 100644 --- a/P3D/Overworld/BackdropRenderer.vb +++ b/P3D/Overworld/BackdropRenderer.vb @@ -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 diff --git a/P3D/Resources/ContentPackManager.vb b/P3D/Resources/ContentPackManager.vb index 93d58e9da..13b992a9f 100644 --- a/P3D/Resources/ContentPackManager.vb +++ b/P3D/Resources/ContentPackManager.vb @@ -9,27 +9,31 @@ If System.IO.File.Exists(ContentPackFile) = True Then Dim Lines() As String = System.IO.File.ReadAllLines(ContentPackFile) For Each Line As String In Lines - Select Case Line.CountSplits("|") - Case 2 'ResolutionChange - Dim TextureName As String = Line.GetSplit(0, "|") - Dim Resolution As Single = CSng(Line.GetSplit(1, "|").Replace(".", GameController.DecSeparator)) + 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, "|") + Dim Resolution As Single = CSng(Line.GetSplit(1, "|").Replace(".", GameController.DecSeparator)) - If TextureResolutions.ContainsKey(TextureName) = False Then - TextureResolutions.Add(TextureName, Resolution) - End If - Case 4 'TextureReplacement - Dim oldTextureName As String = Line.GetSplit(0, "|") - Dim newTextureName As String = Line.GetSplit(2, "|") - Dim oRS As String = Line.GetSplit(1, "|") 'oRS = oldRectangleSource - Dim nRS As String = Line.GetSplit(3, "|") 'nRS = newRectangleSource + If TextureResolutions.ContainsKey(TextureName) = False Then + TextureResolutions.Add(TextureName, Resolution) + End If + Case 4 'TextureReplacement + Dim oldTextureName As String = Line.GetSplit(0, "|") + Dim newTextureName As String = Line.GetSplit(2, "|") + Dim oRS As String = Line.GetSplit(1, "|") 'oRS = oldRectangleSource + Dim nRS As String = Line.GetSplit(3, "|") 'nRS = newRectangleSource - Dim oldTextureSource As New TextureSource(oldTextureName, New Rectangle(CInt(oRS.GetSplit(0)), CInt(oRS.GetSplit(1)), CInt(oRS.GetSplit(2)), CInt(oRS.GetSplit(3)))) - Dim newTextureSource As New TextureSource(newTextureName, New Rectangle(CInt(nRS.GetSplit(0)), CInt(nRS.GetSplit(1)), CInt(nRS.GetSplit(2)), CInt(nRS.GetSplit(3)))) + Dim oldTextureSource As New TextureSource(oldTextureName, New Rectangle(CInt(oRS.GetSplit(0)), CInt(oRS.GetSplit(1)), CInt(oRS.GetSplit(2)), CInt(oRS.GetSplit(3)))) + Dim newTextureSource As New TextureSource(newTextureName, New Rectangle(CInt(nRS.GetSplit(0)), CInt(nRS.GetSplit(1)), CInt(nRS.GetSplit(2)), CInt(nRS.GetSplit(3)))) - If TextureReplacements.ContainsKey(oldTextureSource) = False Then - TextureReplacements.Add(oldTextureSource, newTextureSource) - End If - End Select + If TextureReplacements.ContainsKey(oldTextureSource) = False Then + TextureReplacements.Add(oldTextureSource, newTextureSource) + End If + End Select + End If Next End If End If diff --git a/P3D/Screens/NewOptionScreen.vb b/P3D/Screens/NewOptionScreen.vb index 85c2d327c..44f75d5fd 100644 --- a/P3D/Screens/NewOptionScreen.vb +++ b/P3D/Screens/NewOptionScreen.vb @@ -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