From c76ee70b083356ddb97f156cff140711ebd275ce Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sun, 29 Oct 2023 13:52:48 +0100 Subject: [PATCH] WaterSpeed can now also be set by GameModes --- P3D/Entites/Enviroment/Water.vb | 4 +--- P3D/Overworld/BackdropRenderer.vb | 6 +++--- P3D/Resources/ContentPackManager.vb | 2 +- P3D/Resources/GameModeManager.vb | 30 ++++++++++++++++++++++++++--- P3D/Screens/NewOptionScreen.vb | 2 +- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/P3D/Entites/Enviroment/Water.vb b/P3D/Entites/Enviroment/Water.vb index 51b25f569..aec90a4b2 100644 --- a/P3D/Entites/Enviroment/Water.vb +++ b/P3D/Entites/Enviroment/Water.vb @@ -9,12 +9,10 @@ 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, WaterSpeed, 15, 0) + WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Routes"), 1, 3, 16, 16, GameModeManager.ActiveGameMode.WaterSpeed, 15, 0) CreateWaterTextureTemp() End Sub diff --git a/P3D/Overworld/BackdropRenderer.vb b/P3D/Overworld/BackdropRenderer.vb index 94e9fd83d..e563b2c9c 100644 --- a/P3D/Overworld/BackdropRenderer.vb +++ b/P3D/Overworld/BackdropRenderer.vb @@ -83,7 +83,7 @@ Dim WaterAnimation As Animation Dim CustomAnimation As Animation - Private _waterAnimationDelay As Single = CSng(1 / Water.WaterSpeed) + Private _waterAnimationDelay As Single = CSng(1 / GameModeManager.ActiveGameMode.WaterSpeed) Private _waterAnimationIndex As Integer = 0 Private _setTexture As Boolean = False @@ -111,7 +111,7 @@ Case "water" Me._backdropType = BackdropTypes.Water Dim WaterSize As Size = New Size(CInt(TextureManager.GetTexture("Textures\Backdrops\Water").Width / 3), CInt(TextureManager.GetTexture("Textures\Backdrops\Water").Height)) - WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Backdrops\Water"), 1, 3, WaterSize.Width, WaterSize.Height, Water.WaterSpeed, 0, 0) + WaterAnimation = New Animation(TextureManager.GetTexture("Textures\Backdrops\Water"), 1, 3, WaterSize.Width, WaterSize.Height, GameModeManager.ActiveGameMode.WaterSpeed, 0, 0) _backdropTexture = TextureManager.GetTexture("Textures\Backdrops\Water", WaterAnimation.TextureRectangle, "") Case "grass" Me._backdropType = BackdropTypes.Grass @@ -124,7 +124,7 @@ Dim _frameCount As Integer If AnimationSpeed = Nothing Then - _animationspeed = Water.WaterSpeed + _animationspeed = GameModeManager.ActiveGameMode.WaterSpeed Else _animationspeed = AnimationSpeed End If diff --git a/P3D/Resources/ContentPackManager.vb b/P3D/Resources/ContentPackManager.vb index e383b8b82..e63d0c06f 100644 --- a/P3D/Resources/ContentPackManager.vb +++ b/P3D/Resources/ContentPackManager.vb @@ -10,7 +10,7 @@ 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, "|")) + GameModeManager.ForceWaterSpeed = CInt(Line.GetSplit(1, "|")) Else Select Case Line.CountSplits("|") Case 2 'ResolutionChange diff --git a/P3D/Resources/GameModeManager.vb b/P3D/Resources/GameModeManager.vb index 01b29a320..049491149 100644 --- a/P3D/Resources/GameModeManager.vb +++ b/P3D/Resources/GameModeManager.vb @@ -3,6 +3,7 @@ Public Class GameModeManager Private Shared GameModeList As New List(Of GameMode) Private Shared GameModePointer As Integer = 0 Public Shared Initialized As Boolean = False + Public Shared ForceWaterSpeed As Integer = -1 ''' ''' Loads (or reloads) the list of GameModes. The pointer also gets reset. @@ -385,7 +386,7 @@ Public Class GameMode ''' The skin names for the new GameMode. Must be the same amount as SkinFiles and SkinColors. ''' The skin names for the new GameMode. Must be the same amount as SkinFiles and SkinColors. Public Sub New(ByVal Name As String, ByVal Description As String, ByVal Version As String, ByVal Author As String, ByVal MapPath As String, ByVal ScriptPath As String, ByVal PokeFilePath As String, ByVal PokemonDataPath As String, ByVal ContentPath As String, ByVal LocalizationsPath As String, ByVal GameRules As List(Of GameRule), ByVal HardGameRules As List(Of GameRule), - ByVal StartMap As String, ByVal StartPosition As Vector3, ByVal StartRotation As Single, ByVal StartLocationName As String, ByVal StartDialogue As String, ByVal StartColor As Color, ByVal PokemonAppear As String, ByVal IntroMusic As String, ByVal IntroType As String, ByVal SkinColors As List(Of Color), ByVal SkinFiles As List(Of String), ByVal SkinNames As List(Of String), ByVal SkinGenders As List(Of String)) + ByVal StartMap As String, ByVal StartPosition As Vector3, ByVal StartRotation As Single, ByVal StartLocationName As String, ByVal StartDialogue As String, ByVal StartColor As Color, ByVal PokemonAppear As String, ByVal IntroMusic As String, ByVal IntroType As String, ByVal SkinColors As List(Of Color), ByVal SkinFiles As List(Of String), ByVal SkinNames As List(Of String), ByVal SkinGenders As List(Of String), Optional WaterSpeed As Integer = 8) Me._name = Name Me._description = Description Me._version = Version @@ -398,6 +399,7 @@ Public Class GameMode Me._localizationsPath = LocalizationsPath Me._gameRules = GameRules Me._hardGameRules = HardGameRules + Me._waterspeed = WaterSpeed Me._startMap = StartMap Me._startPosition = StartPosition @@ -479,6 +481,8 @@ Public Class GameMode End If Next End If + Case "waterspeed" + Me._waterspeed = CInt(Value) Case "startmap" Me._startMap = Value Case "startposition" @@ -590,7 +594,7 @@ Public Class GameMode Dim SkinGenders As List(Of String) = {"Male", "Female", "Male", "Female", "Male", "Female"}.ToList() Dim gameMode As New GameMode("Kolben", "The normal game mode.", GameController.GAMEVERSION, "Kolben Games", "\Content\Data\maps\", "\Content\Data\Scripts\", "\Content\Data\maps\poke\", "\Content\Pokemon\Data\", "\Content\", "\Content\Localization\", New List(Of GameRule), New List(Of GameRule), - "newgame\intro0.dat", New Vector3(1.0F, 0.1F, 3.0F), MathHelper.PiOver2, "Your Room", "", New Color(59, 123, 165), "0", "welcome", "1", SkinColors, SkinFiles, SkinNames, SkinGenders) + "newgame\intro0.dat", New Vector3(1.0F, 0.1F, 3.0F), MathHelper.PiOver2, "Your Room", "", New Color(59, 123, 165), "0", "welcome", "1", SkinColors, SkinFiles, SkinNames, SkinGenders, 8) gameMode.StartScript = "startscript\main" @@ -634,7 +638,9 @@ Public Class GameMode "PokeFilePath|" & Me._pokeFilePath & Environment.NewLine & "PokemonDataPath|" & Me._pokemonDataPath & Environment.NewLine & "ContentPath|" & Me._contentPath & Environment.NewLine & - "LocalizationsPath|" & Me._localizationsPath & Environment.NewLine + "LocalizationsPath|" & Me._localizationsPath & Environment.NewLine & + "WaterSpeed|" & _waterspeed & Environment.NewLine + Dim GameRuleString As String = "GameRules|" For Each rule As GameRule In Me._gameRules @@ -755,6 +761,7 @@ Public Class GameMode Private _contentPath As String = "" Private _gameRules As New List(Of GameRule) Private _hardGameRules As New List(Of GameRule) + Private _waterspeed As Integer = 8 ''' ''' The name of this GameMode. @@ -875,6 +882,23 @@ Public Class GameMode Me._localizationsPath = value End Set End Property + ''' + ''' The speed at which water should animate. + ''' + Public Property WaterSpeed As Integer + Get + If GameModeManager.ForceWaterSpeed <> -1 Then + Return GameModeManager.ForceWaterSpeed + Else + Return Me._waterspeed + End If + + End Get + Set(value As Integer) + Me._waterspeed = value + End Set + End Property + ''' ''' The GameRules that apply to this GameMode. diff --git a/P3D/Screens/NewOptionScreen.vb b/P3D/Screens/NewOptionScreen.vb index 1f9ae588d..394c6d608 100644 --- a/P3D/Screens/NewOptionScreen.vb +++ b/P3D/Screens/NewOptionScreen.vb @@ -516,7 +516,7 @@ Public Class NewOptionScreen FontManager.LoadFonts() MusicManager.PlayNoMusic() ContentPackManager.Clear() - Water.WaterSpeed = 8 + GameModeManager.ForceWaterSpeed = -1 For Each s As String In Core.GameOptions.ContentPackNames ContentPackManager.Load(GameController.GamePath & "\ContentPacks\" & s & "\exceptions.dat") Next