mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-07-24 22:35:47 +02:00
Made the following changes related to Animated blocks:
- Renamed AnimatedTile to AnimatedBlock, and added support for multiple animations. - Fixed bug related to start row and column in the Animation.vb class - Added intArr2D tag content type in LevelLoader
This commit is contained in:
parent
d6d6437ee1
commit
15cd1f3079
@ -208,7 +208,7 @@
|
|||||||
<Compile Include="Entites\Enviroment\WallBill.vb" />
|
<Compile Include="Entites\Enviroment\WallBill.vb" />
|
||||||
<Compile Include="Entites\Enviroment\WallBlock.vb" />
|
<Compile Include="Entites\Enviroment\WallBlock.vb" />
|
||||||
<Compile Include="Entites\Enviroment\WarpBlock.vb" />
|
<Compile Include="Entites\Enviroment\WarpBlock.vb" />
|
||||||
<Compile Include="Entites\Enviroment\AnimatedTile.vb" />
|
<Compile Include="Entites\Enviroment\AnimatedBlock.vb" />
|
||||||
<Compile Include="Entites\Enviroment\Water.vb" />
|
<Compile Include="Entites\Enviroment\Water.vb" />
|
||||||
<Compile Include="Entites\Enviroment\Waterfall.vb" />
|
<Compile Include="Entites\Enviroment\Waterfall.vb" />
|
||||||
<Compile Include="Entites\Enviroment\Whirlpool.vb" />
|
<Compile Include="Entites\Enviroment\Whirlpool.vb" />
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
Me.UpdateEntity()
|
Me.UpdateEntity()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Shared Function GetNewEntity(ByVal EntityID As String, ByVal Position As Vector3, ByVal Textures() As Texture2D, ByVal TextureIndex() As Integer, ByVal Collision As Boolean, ByVal Rotation As Vector3, ByVal Scale As Vector3, ByVal Model As BaseModel, ByVal ActionValue As Integer, ByVal AdditionalValue As String, ByVal Visible As Boolean, ByVal Shader As Vector3, ByVal ID As Integer, ByVal MapOrigin As String, ByVal SeasonColorTexture As String, ByVal Offset As Vector3, Optional ByVal Params() As Object = Nothing, Optional ByVal Opacity As Single = 1.0F, Optional ByVal AnimationData As List(Of Integer) = Nothing) As Entity
|
Public Shared Function GetNewEntity(ByVal EntityID As String, ByVal Position As Vector3, ByVal Textures() As Texture2D, ByVal TextureIndex() As Integer, ByVal Collision As Boolean, ByVal Rotation As Vector3, ByVal Scale As Vector3, ByVal Model As BaseModel, ByVal ActionValue As Integer, ByVal AdditionalValue As String, ByVal Visible As Boolean, ByVal Shader As Vector3, ByVal ID As Integer, ByVal MapOrigin As String, ByVal SeasonColorTexture As String, ByVal Offset As Vector3, Optional ByVal Params() As Object = Nothing, Optional ByVal Opacity As Single = 1.0F, Optional ByVal AnimationData As List(Of List(Of Integer)) = Nothing) As Entity
|
||||||
Dim newEnt As New Entity()
|
Dim newEnt As New Entity()
|
||||||
Dim propertiesEnt As New Entity()
|
Dim propertiesEnt As New Entity()
|
||||||
|
|
||||||
@ -146,10 +146,10 @@
|
|||||||
propertiesEnt.Offset = Offset
|
propertiesEnt.Offset = Offset
|
||||||
|
|
||||||
Select Case EntityID.ToLower()
|
Select Case EntityID.ToLower()
|
||||||
Case "animatedtile"
|
Case "animatedblock"
|
||||||
newEnt = New AnimatedTile()
|
newEnt = New AnimatedBlock()
|
||||||
SetProperties(newEnt, propertiesEnt)
|
SetProperties(newEnt, propertiesEnt)
|
||||||
CType(newEnt, AnimatedTile).Initialize(AnimationData)
|
CType(newEnt, AnimatedBlock).Initialize(AnimationData)
|
||||||
Case "wallblock"
|
Case "wallblock"
|
||||||
newEnt = New WallBlock()
|
newEnt = New WallBlock()
|
||||||
SetProperties(newEnt, propertiesEnt)
|
SetProperties(newEnt, propertiesEnt)
|
||||||
|
@ -1,51 +1,80 @@
|
|||||||
Public Class AnimatedTile
|
Public Class AnimatedBlock
|
||||||
|
|
||||||
Inherits Entity
|
Inherits Entity
|
||||||
|
|
||||||
Shared TileTexturesTemp As New Dictionary(Of String, Texture2D)
|
Shared BlockTexturesTemp As New Dictionary(Of String, Texture2D)
|
||||||
Dim TileTextureName As String = ""
|
|
||||||
|
|
||||||
Dim tileAnimation As Animation
|
|
||||||
Dim currentRectangle As New Rectangle(0, 0, 0, 0)
|
|
||||||
|
|
||||||
Dim rows, columns, animationSpeed, startRow, startColumn As Integer
|
|
||||||
|
|
||||||
|
|
||||||
Public Overloads Sub Initialize(ByVal AnimationData As List(Of Integer))
|
Dim AnimationNames As List(Of String)
|
||||||
|
|
||||||
|
Dim Animations As List(Of Animation)
|
||||||
|
Dim currentRectangle As List(Of Rectangle)
|
||||||
|
|
||||||
|
Dim X, Y, width, height, rows, columns, animationSpeed, startRow, startColumn As List(Of Integer)
|
||||||
|
|
||||||
|
Dim AnimCount As Integer = 0
|
||||||
|
|
||||||
|
|
||||||
|
Sub New()
|
||||||
|
X = New List(Of Integer)
|
||||||
|
Y = New List(Of Integer)
|
||||||
|
width = New List(Of Integer)
|
||||||
|
height = New List(Of Integer)
|
||||||
|
rows = New List(Of Integer)
|
||||||
|
columns = New List(Of Integer)
|
||||||
|
animationSpeed = New List(Of Integer)
|
||||||
|
startRow = New List(Of Integer)
|
||||||
|
startColumn = New List(Of Integer)
|
||||||
|
|
||||||
|
AnimationNames = New List(Of String)
|
||||||
|
currentRectangle = New List(Of Rectangle)
|
||||||
|
Animations = New List(Of Animation)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Overloads Sub Initialize(ByVal AnimationData As List(Of List(Of Integer)))
|
||||||
|
|
||||||
MyBase.Initialize()
|
MyBase.Initialize()
|
||||||
rows = AnimationData(0)
|
For i = 0 To AnimationData.Count - 1
|
||||||
columns = AnimationData(1)
|
X.Add(AnimationData(i)(0))
|
||||||
animationSpeed = AnimationData(2)
|
Y.Add(AnimationData(i)(1))
|
||||||
startRow = AnimationData(3)
|
width.Add(AnimationData(i)(2))
|
||||||
startColumn = AnimationData(4)
|
height.Add(AnimationData(i)(3))
|
||||||
|
rows.Add(AnimationData(i)(4))
|
||||||
|
columns.Add(AnimationData(i)(5))
|
||||||
|
animationSpeed.Add(AnimationData(i)(6))
|
||||||
|
startRow.Add(AnimationData(i)(7))
|
||||||
|
startColumn.Add(AnimationData(i)(8))
|
||||||
|
|
||||||
tileAnimation = New Animation(TextureManager.GetTexture("Textures\Routes"), rows, columns, 16, 16, animationSpeed, startRow, startColumn)
|
AnimationNames.Add("")
|
||||||
|
currentRectangle.Add(New Rectangle(0, 0, 0, 0))
|
||||||
|
|
||||||
CreateTileTextureTemp()
|
Animations.Add(New Animation(TextureManager.GetTexture("Textures\Routes"), rows(i), columns(i), 16, 16, animationSpeed(i), startRow(i), startColumn(i)))
|
||||||
|
|
||||||
|
AnimCount += 1
|
||||||
|
Next
|
||||||
|
|
||||||
|
CreateBlockTextureTemp()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Shared Sub ClearAnimationResources()
|
Public Shared Sub ClearAnimationResources()
|
||||||
TileTexturesTemp.Clear()
|
BlockTexturesTemp.Clear()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CreateTileTextureTemp()
|
Private Sub CreateBlockTextureTemp()
|
||||||
'If Core.GameOptions.GraphicStyle = 1 Then
|
'If Core.GameOptions.GraphicStyle = 1 Then
|
||||||
Dim textureData As List(Of String) = Me.AdditionalValue.Split(CChar(",")).ToList()
|
|
||||||
If textureData.Count >= 5 Then
|
For n = 0 To Animations.Count - 1
|
||||||
Dim r As New Rectangle(CInt(textureData(1)), CInt(textureData(2)), CInt(textureData(3)), CInt(textureData(4)))
|
Dim r As New Rectangle(X(n), Y(n), width(n), height(n))
|
||||||
Dim texturePath As String = textureData(0)
|
Me.AnimationNames(n) = AdditionalValue & "," & X(n) & "," & Y(n) & "," & height(n) & "," & width(n)
|
||||||
Me.TileTextureName = AdditionalValue
|
If BlockTexturesTemp.ContainsKey(AnimationNames(n) & "_0") = False Then
|
||||||
If AnimatedTile.TileTexturesTemp.ContainsKey(AdditionalValue & "_0") = False Then
|
For i = 0 To Me.rows(n) - 1
|
||||||
For i = 0 To Me.rows - 1
|
For j = 0 To Me.columns(n) - 1
|
||||||
For j = 0 To Me.columns - 1
|
BlockTexturesTemp.Add(AnimationNames(n) & "_" & (j + columns(n) * i).ToString, TextureManager.GetTexture(AdditionalValue, New Rectangle(r.X + r.Width * j, r.Y + r.Height * i, r.Width, r.Height)))
|
||||||
AnimatedTile.TileTexturesTemp.Add(AdditionalValue & "_" & (j + columns * i).ToString, TextureManager.GetTexture(texturePath, New Rectangle(r.X + r.Width * j, r.Y + r.Height * i, r.Width, r.Height)))
|
|
||||||
Next
|
Next
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
Else
|
Next
|
||||||
Logger.Log(Logger.LogTypes.ErrorMessage, "AnimatedTile.vb: invalid AdditionalValue parameters")
|
|
||||||
End If
|
|
||||||
'End If
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Overrides Sub ClickFunction()
|
Public Overrides Sub ClickFunction()
|
||||||
@ -68,7 +97,7 @@
|
|||||||
|
|
||||||
For Each Entity As Entity In Screen.Level.Entities
|
For Each Entity As Entity In Screen.Level.Entities
|
||||||
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
||||||
If Entity.EntityID = "Water" Then
|
If Entity.ActionValue = 0 AndAlso (Entity.EntityID = "AnimatedBlock" OrElse Entity.EntityID = "Water") Then
|
||||||
canSurf = True
|
canSurf = True
|
||||||
Else
|
Else
|
||||||
If Entity.Collision = True Then
|
If Entity.Collision = True Then
|
||||||
@ -97,7 +126,7 @@
|
|||||||
If Me.ActionValue = 0 Then
|
If Me.ActionValue = 0 Then
|
||||||
For Each Entity As Entity In Screen.Level.Entities
|
For Each Entity As Entity In Screen.Level.Entities
|
||||||
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
||||||
If Entity.EntityID = "Water" Then
|
If Entity.EntityID = "AnimatedBlock" Then
|
||||||
If Core.Player.SurfPokemon > -1 Then
|
If Core.Player.SurfPokemon > -1 Then
|
||||||
canSurf = True
|
canSurf = True
|
||||||
End If
|
End If
|
||||||
@ -132,27 +161,30 @@
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Overrides Sub UpdateEntity()
|
Public Overrides Sub UpdateEntity()
|
||||||
If Not tileAnimation Is Nothing Then
|
If Not Animations Is Nothing Then
|
||||||
tileAnimation.Update(0.01)
|
For n = 0 To Animations.Count - 1
|
||||||
If currentRectangle <> tileAnimation.TextureRectangle Then
|
Animations(n).Update(0.01)
|
||||||
ChangeTexture()
|
If currentRectangle(n) <> Animations(n).TextureRectangle Then
|
||||||
|
ChangeTexture(n)
|
||||||
|
|
||||||
currentRectangle = tileAnimation.TextureRectangle
|
currentRectangle(n) = Animations(n).TextureRectangle
|
||||||
End If
|
End If
|
||||||
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
MyBase.UpdateEntity()
|
MyBase.UpdateEntity()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub ChangeTexture()
|
Private Sub ChangeTexture(ByVal n As Integer)
|
||||||
'If Core.GameOptions.GraphicStyle = 1 Then
|
'If Core.GameOptions.GraphicStyle = 1 Then
|
||||||
If TileTexturesTemp.Count = 0 Then
|
|
||||||
|
If BlockTexturesTemp.Count = 0 Then
|
||||||
ClearAnimationResources()
|
ClearAnimationResources()
|
||||||
CreateTileTextureTemp()
|
CreateBlockTextureTemp()
|
||||||
End If
|
End If
|
||||||
Dim i = tileAnimation.CurrentRow
|
Dim i = Animations(n).CurrentRow
|
||||||
Dim j = tileAnimation.CurrentColumn
|
Dim j = Animations(n).CurrentColumn
|
||||||
Me.Textures(0) = AnimatedTile.TileTexturesTemp(TileTextureName & "_" & (j + columns * i))
|
Me.Textures(n) = AnimatedBlock.BlockTexturesTemp(AnimationNames(n) & "_" & (j + columns(n) * i))
|
||||||
|
|
||||||
'End If
|
'End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
@ -144,10 +144,10 @@ Public Class Animation
|
|||||||
CurrentColumn += 1
|
CurrentColumn += 1
|
||||||
If CurrentColumn >= Columns Then
|
If CurrentColumn >= Columns Then
|
||||||
CurrentRow += 1
|
CurrentRow += 1
|
||||||
CurrentColumn = StartColumn
|
CurrentColumn = 0
|
||||||
|
|
||||||
If CurrentRow >= Rows Then
|
If CurrentRow >= Rows Then
|
||||||
CurrentRow = StartRow
|
CurrentRow = 0
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
@ -320,6 +320,20 @@
|
|||||||
arr.Add(CInt(value))
|
arr.Add(CInt(value))
|
||||||
Next
|
Next
|
||||||
Dictionary.Add(TagName, arr)
|
Dictionary.Add(TagName, arr)
|
||||||
|
Case "intarr2d"
|
||||||
|
Dim rows() As String = subTagValue.Split(CChar("]"))
|
||||||
|
Dim arr As New List(Of List(Of Integer))
|
||||||
|
For Each row As String In rows
|
||||||
|
If row.Length > 0 Then
|
||||||
|
row = row.Remove(0, 1)
|
||||||
|
Dim list As New List(Of Integer)
|
||||||
|
For Each value In row.Split(CChar(","))
|
||||||
|
list.Add(CInt(value))
|
||||||
|
Next
|
||||||
|
arr.Add(list)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Dictionary.Add(TagName, arr)
|
||||||
Case "rec"
|
Case "rec"
|
||||||
Dim content() As String = subTagValue.Split(CChar(","))
|
Dim content() As String = subTagValue.Split(CChar(","))
|
||||||
Dictionary.Add(TagName, New Rectangle(CInt(content(0)), CInt(content(1)), CInt(content(2)), CInt(content(3))))
|
Dictionary.Add(TagName, New Rectangle(CInt(content(0)), CInt(content(1)), CInt(content(2)), CInt(content(3))))
|
||||||
@ -806,9 +820,9 @@
|
|||||||
AdditionalValue = CStr(GetTag(Tags, "AdditionalValue"))
|
AdditionalValue = CStr(GetTag(Tags, "AdditionalValue"))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim AnimationData As List(Of Integer) = Nothing
|
Dim AnimationData As List(Of List(Of Integer)) = Nothing
|
||||||
If TagExists(Tags, "AnimationData") = True Then
|
If TagExists(Tags, "AnimationData") = True Then
|
||||||
AnimationData = CType(GetTag(Tags, "AnimationData"), List(Of Integer))
|
AnimationData = CType(GetTag(Tags, "AnimationData"), List(Of List(Of Integer)))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim Rotation As Vector3 = Entity.GetRotationFromInteger(CInt(GetTag(Tags, "Rotation")))
|
Dim Rotation As Vector3 = Entity.GetRotationFromInteger(CInt(GetTag(Tags, "Rotation")))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user