From 3ef08819a9f21069d49c7cd8b7756e0d8be122fd Mon Sep 17 00:00:00 2001 From: Aragas Date: Thu, 6 Oct 2016 18:25:33 +0300 Subject: [PATCH] The dirty fixes: Part 2 --- 2.5DHero/2.5DHero/Entites/Other/NPC.vb | 9 ++++++++- 2.5DHero/2.5DHero/Entites/Other/NetworkPlayer.vb | 16 ++++++++++++---- .../2.5DHero/Entites/Other/NetworkPokemon.vb | 14 +++++++++++--- .../2.5DHero/Entites/Other/OverworldPokemon.vb | 9 ++++++++- 2.5DHero/2.5DHero/Entites/Other/OwnPlayer.vb | 9 ++++++++- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/2.5DHero/2.5DHero/Entites/Other/NPC.vb b/2.5DHero/2.5DHero/Entites/Other/NPC.vb index bbe83d9e2..ed4cd5631 100644 --- a/2.5DHero/2.5DHero/Entites/Other/NPC.vb +++ b/2.5DHero/2.5DHero/Entites/Other/NPC.vb @@ -225,6 +225,7 @@ Return 1 End Function + Dim dispTex As Boolean = false Private Sub ChangeTexture() If Not Me.Texture Is Nothing Then Dim r As New Rectangle(0, 0, 0, 0) @@ -271,8 +272,9 @@ If r <> lastRectangle Then lastRectangle = r - Dim t As Texture2D = net.Pokemon3D.Game.TextureManager.TextureRectangle(Me.Texture, r, 1) + Dim t As Texture2D = TextureManager.TextureRectangle(Me.Texture, r, 1) Textures(0) = t + dispTex = true End If End If End Sub @@ -747,4 +749,9 @@ #End Region + Protected Overrides Sub Finalize() + If Textures(0) IsNot Nothing And dispTex + Textures(0).Dispose() + End If + End Sub End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Entites/Other/NetworkPlayer.vb b/2.5DHero/2.5DHero/Entites/Other/NetworkPlayer.vb index 24b74784c..e7599654c 100644 --- a/2.5DHero/2.5DHero/Entites/Other/NetworkPlayer.vb +++ b/2.5DHero/2.5DHero/Entites/Other/NetworkPlayer.vb @@ -84,7 +84,7 @@ If Not OnlineSprite Is Nothing Then Me.Texture = OnlineSprite Else - If net.Pokemon3D.Game.TextureManager.TextureExist(texturePath) = True Then + If TextureManager.TextureExist(texturePath) = True Then Logger.Debug("Change network texture to [" & texturePath & "]") If texturePath.StartsWith("Pokemon\") = True Then @@ -93,10 +93,10 @@ Me.HasPokemonTexture = False End If - Me.Texture = net.Pokemon3D.Game.TextureManager.GetTexture(texturePath) + Me.Texture = TextureManager.GetTexture(texturePath) Else Logger.Debug("Texture fallback!") - Me.Texture = net.Pokemon3D.Game.TextureManager.GetTexture("Textures\NPC\" & FallBack(Me.NetworkID)) + Me.Texture = TextureManager.GetTexture("Textures\NPC\" & FallBack(Me.NetworkID)) End If End If End Sub @@ -124,6 +124,7 @@ Return texturePath & TextureID End Function + Dim dispTex As Boolean = false Private Sub ChangeTexture() If Not Me.Texture Is Nothing Then Dim r As New Rectangle(0, 0, 0, 0) @@ -156,8 +157,9 @@ If r <> lastRectangle Then lastRectangle = r - Dim t As Texture2D = net.Pokemon3D.Game.TextureManager.TextureRectangle(Me.Texture, r, 1) + Dim t As Texture2D = TextureManager.TextureRectangle(Me.Texture, r, 1) Textures(0) = t + dispTex = true End If End If End Sub @@ -370,4 +372,10 @@ Return Nothing End Function + Protected Overrides Sub Finalize() + If Textures(0) IsNot Nothing And dispTex + Textures(0).Dispose() + End If + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Entites/Other/NetworkPokemon.vb b/2.5DHero/2.5DHero/Entites/Other/NetworkPokemon.vb index 2e27be01a..c64a8e22b 100644 --- a/2.5DHero/2.5DHero/Entites/Other/NetworkPokemon.vb +++ b/2.5DHero/2.5DHero/Entites/Other/NetworkPokemon.vb @@ -16,7 +16,7 @@ Dim AnimationDelay As Single = AnimationDelayLenght Public Sub New(ByVal pos As Vector3, ByVal PokemonTexture As String, ByVal visible As Boolean) - MyBase.New(pos.X, pos.Y, pos.Z, "NetworkPokemon", {net.Pokemon3D.Game.TextureManager.DefaultTexture}, {0, 0}, False, 0, New Vector3(0.9F), BaseModel.BillModel, 0, "", New Vector3(1)) + MyBase.New(pos.X, pos.Y, pos.Z, "NetworkPokemon", {TextureManager.DefaultTexture}, {0, 0}, False, 0, New Vector3(0.9F), BaseModel.BillModel, 0, "", New Vector3(1)) Me.Visible = visible @@ -97,10 +97,11 @@ Return True End Function + Dim dispTex As Boolean = false Private Sub ChangeTexture() If Me.Texture Is Nothing Then Dim path As String = Me.PokemonTexture.Replace("[POKEMON|N]", "Pokemon\Overworld\Normal\").Replace("[POKEMON|S]", "Pokemon\Overworld\Shiny\") - Me.Texture = net.Pokemon3D.Game.TextureManager.GetTexture(path) + Me.Texture = TextureManager.GetTexture(path) End If Dim r As New Rectangle(0, 0, 0, 0) @@ -133,8 +134,9 @@ If r <> lastRectangle Then lastRectangle = r - Dim t As Texture2D = net.Pokemon3D.Game.TextureManager.TextureRectangle(Me.Texture, r, 1) + Dim t As Texture2D = TextureManager.TextureRectangle(Me.Texture, r, 1) Textures(0) = t + dispTex = true End If End Sub @@ -173,4 +175,10 @@ Catch : End Try End Sub + Protected Overrides Sub Finalize() + If Textures(0) IsNot Nothing And dispTex + Textures(0).Dispose() + End If + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Entites/Other/OverworldPokemon.vb b/2.5DHero/2.5DHero/Entites/Other/OverworldPokemon.vb index 481d242a9..2644eaeb8 100644 --- a/2.5DHero/2.5DHero/Entites/Other/OverworldPokemon.vb +++ b/2.5DHero/2.5DHero/Entites/Other/OverworldPokemon.vb @@ -34,6 +34,7 @@ Public Class OverworldPokemon Me.DropUpdateUnlessDrawn = False End Sub + Dim dispTex As Boolean = false Private Sub ChangeTexture() If Me.Texture Is Nothing Then Me.Texture = PokemonReference.GetOverworldTexture() @@ -62,8 +63,9 @@ Public Class OverworldPokemon If r <> lastRectangle Then lastRectangle = r - Dim t As Texture2D = net.Pokemon3D.Game.TextureManager.TextureRectangle(Me.Texture, r, 1) + Dim t As Texture2D = TextureManager.TextureRectangle(Me.Texture, r, 1) Textures(0) = t + dispTex = true End If End Sub @@ -269,4 +271,9 @@ Public Class OverworldPokemon Me.ChangeTexture() End Sub + Protected Overrides Sub Finalize() + If Textures(0) IsNot Nothing And dispTex + Textures(0).Dispose() + End If + End Sub End Class diff --git a/2.5DHero/2.5DHero/Entites/Other/OwnPlayer.vb b/2.5DHero/2.5DHero/Entites/Other/OwnPlayer.vb index 8bb768cfb..10a82df0e 100644 --- a/2.5DHero/2.5DHero/Entites/Other/OwnPlayer.vb +++ b/2.5DHero/2.5DHero/Entites/Other/OwnPlayer.vb @@ -113,6 +113,7 @@ End If End Sub + Dim dispTex As Boolean = false Public Sub ChangeTexture() If Not Me.Texture Is Nothing Then Dim r As New Rectangle(0, 0, 0, 0) @@ -146,8 +147,9 @@ Core.Player.Skin = SkinName Try - Dim t As Texture2D = net.Pokemon3D.Game.TextureManager.TextureRectangle(Me.Texture, r, 1) + Dim t As Texture2D = TextureManager.TextureRectangle(Me.Texture, r, 1) Textures(0) = t + dispTex = true Catch Logger.Log(Logger.LogTypes.Warning, "OwnPlayer.vb: Error assigning a new texture to the player.") End Try @@ -205,4 +207,9 @@ Return OwnPlayer.AnimationDelayLenght End Function + Protected Overrides Sub Finalize() + If Textures(0) IsNot Nothing And dispTex + Textures(0).Dispose() + End If + End Sub End Class \ No newline at end of file