P3D-Legacy/P3D/Battle/BattleAnimations/BAEntityColor.vb

99 lines
3.7 KiB
VB.net
Raw Normal View History

Public Class BAEntityColor
Inherits BattleAnimation3D
Public TargetEntity As Entity
Public TransitionSpeed As Single = 0.01F
2023-09-06 12:13:24 +02:00
Public TransitionSpeedOut As Single = 0.01F
Public FadeIn As Boolean = False
2023-09-06 12:13:24 +02:00
Public ReturnToFromWhenDone As Boolean = False
Public RemoveEntityAfter As Boolean = False
Public InitialColorSet As Boolean = False
Public IsReturning As Boolean = False
Public ColorTo As Vector3 = New Vector3(1.0F, 1.0F, 1.0F)
2023-09-06 12:13:24 +02:00
Public ColorFrom As Vector3 = New Vector3(1.0F, 1.0F, 1.0F)
2023-09-06 12:13:24 +02:00
Public Sub New(ByVal Entity As Entity, ByVal RemoveEntityAfter As Boolean, ByVal TransitionSpeedIn As Single, ByVal ReturnToFromWhenDone As Boolean, ByVal startDelay As Single, ByVal endDelay As Single, ByVal ColorTo As Vector3, Optional ByVal ColorFrom As Vector3 = Nothing, Optional TransitionSpeedOut As Single = -1)
MyBase.New(New Vector3(0.0F), TextureManager.DefaultTexture, New Vector3(1.0F), startDelay, endDelay)
2023-09-06 12:13:24 +02:00
Me.RemoveEntityAfter = RemoveEntityAfter
If TransitionSpeedOut = -1 Then
Me.TransitionSpeedOut = TransitionSpeedIn
Else
Me.TransitionSpeedOut = TransitionSpeedOut
End If
Me.TransitionSpeed = TransitionSpeedIn
Me.TargetEntity = Entity
2023-09-06 12:13:24 +02:00
Me.ReturnToFromWhenDone = ReturnToFromWhenDone
If Not ColorFrom = Nothing Then
2023-09-06 12:13:24 +02:00
Me.ColorFrom = ColorFrom
Else
Me.ColorFrom = TargetEntity.Color
End If
2023-09-06 12:13:24 +02:00
Me.ColorTo = ColorTo
Me.Visible = False
Me.AnimationType = AnimationTypes.Transition
End Sub
Public Overrides Sub DoActionActive()
2023-09-06 12:13:24 +02:00
If InitialColorSet = False Then
TargetEntity.Color = ColorFrom
InitialColorSet = True
End If
If TargetEntity.Color.X > ColorTo.X Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.X -= Me.TransitionSpeed
If TargetEntity.Color.X <= ColorTo.X Then
TargetEntity.Color.X = ColorTo.X
End If
ElseIf TargetEntity.Color.X < ColorTo.X Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.X += Me.TransitionSpeed
If TargetEntity.Color.X >= ColorTo.X Then
TargetEntity.Color.X = ColorTo.X
End If
End If
If TargetEntity.Color.Y > ColorTo.Y Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.Y -= Me.TransitionSpeed
If TargetEntity.Color.Y <= ColorTo.Y Then
TargetEntity.Color.Y = ColorTo.Y
End If
ElseIf TargetEntity.Color.Y < ColorTo.Y Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.Y += Me.TransitionSpeed
If TargetEntity.Color.Y >= ColorTo.Y Then
TargetEntity.Color.Y = ColorTo.Y
End If
End If
If TargetEntity.Color.Z > ColorTo.Z Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.Z -= Me.TransitionSpeed
If TargetEntity.Color.Z <= ColorTo.Z Then
TargetEntity.Color.Z = ColorTo.Z
End If
ElseIf TargetEntity.Color.Z < ColorTo.Z Then
2023-09-06 12:13:24 +02:00
TargetEntity.Color.Z += Me.TransitionSpeed
If TargetEntity.Color.Z >= ColorTo.Z Then
TargetEntity.Color.Z = ColorTo.Z
End If
End If
If TargetEntity.Color = ColorTo Then
2023-09-06 12:13:24 +02:00
If ReturnToFromWhenDone = False Then
Me.Ready = True
Else
If IsReturning = False Then
ColorTo = ColorFrom
TransitionSpeed = TransitionSpeedOut
IsReturning = True
Else
Me.Ready = True
End If
End If
End If
End Sub
Public Overrides Sub DoRemoveEntity()
If Me.RemoveEntityAfter = True Then
TargetEntity.CanBeRemoved = True
End If
End Sub
End Class