mirror of
https://github.com/RDCN-Community-Developers/rdkt.git
synced 2026-09-04 17:25:33 +08:00
Added CustomFlashEvent.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package cn.rdlevel.rdkt.core.events
|
||||
|
||||
|
||||
import cn.rdlevel.rdkt.core.data.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Emits a flash with custom settings.
|
||||
* @property startColor The start color of the flash.
|
||||
* @property startOpacity The start opacity of the flash.
|
||||
* @property endColor The end color of the flash.
|
||||
* @property endOpacity The end opacity of the flash.
|
||||
* @property background Whether the flash should be a background flash or a foreground flash.
|
||||
*/
|
||||
@Serializable
|
||||
@SerialName("CustomFlash")
|
||||
public data class CustomFlashEvent(
|
||||
var startColor: Color? = WHITE,
|
||||
var startOpacity: Int? = 100,
|
||||
var endColor: Color? = WHITE,
|
||||
var endOpacity: Int? = 0,
|
||||
var background: Boolean = false,
|
||||
override var duration: Double = 2.0,
|
||||
override var ease: Easing = Easing.LINEAR,
|
||||
override var rooms: RoomsOrTopLayer = roomsOf(ROOM1),
|
||||
) : ActionEvent(), MutableRoomsOrTopLayerSpecificEvent, DurationEaseSpecificEvent {
|
||||
/**
|
||||
* The start color and opacity converted into [ColorWithAlpha].
|
||||
* It will be null if either the color or the opacity is null.
|
||||
*/
|
||||
var start: ColorWithAlpha?
|
||||
get() = startOpacity?.let { startColor?.withAlpha((it * 255 / 100).coerceIn(0, 255)) }
|
||||
set(value) {
|
||||
startColor = value
|
||||
startOpacity = value?.alpha?.let { it * 100 / 255 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The end color and opacity converted into [ColorWithAlpha].
|
||||
* It will be null if either the color or the opacity is null.
|
||||
*/
|
||||
var end: ColorWithAlpha?
|
||||
get() = endOpacity?.let { endColor?.withAlpha((it * 255 / 100).coerceIn(0, 255)) }
|
||||
set(value) {
|
||||
endColor = value
|
||||
endOpacity = value?.alpha?.let { it * 100 / 255 }
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,21 @@ public interface DurationSpecificEvent : Event {
|
||||
public var duration: Double
|
||||
}
|
||||
|
||||
/**
|
||||
* An [Event] that has an easing, meaning it can have a smooth transition over time.
|
||||
*/
|
||||
public interface EaseSpecificEvent : Event {
|
||||
/**
|
||||
* The easing of the event.
|
||||
*/
|
||||
public var ease: Easing
|
||||
}
|
||||
|
||||
/**
|
||||
* An [Event] that both has a duration and an easing.
|
||||
*/
|
||||
public interface DurationEaseSpecificEvent : DurationSpecificEvent, EaseSpecificEvent
|
||||
|
||||
/**
|
||||
* An [Event] that is specific to a single row.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ public data class SetBackgroundColorEvent(
|
||||
@Flatten
|
||||
private var type: GroundType,
|
||||
var filter: RescaleFilter = RescaleFilter.NEAREST_NEIGHBOR,
|
||||
override val rooms: RoomsOrTopLayer = roomsOf(ROOM1),
|
||||
) : ActionEvent(), RoomsOrTopLayerSpecificEvent {
|
||||
override var rooms: RoomsOrTopLayer = roomsOf(ROOM1),
|
||||
) : ActionEvent(), MutableRoomsOrTopLayerSpecificEvent {
|
||||
public object Serializer : KSerializer<SetBackgroundColorEvent> by generatedSerializer().flatten()
|
||||
}
|
||||
@@ -11,13 +11,17 @@ import cn.rdlevel.rdkt.core.serialization.Flatten
|
||||
import cn.rdlevel.rdkt.core.serialization.flatten
|
||||
import kotlinx.serialization.*
|
||||
|
||||
/**
|
||||
* Set foreground of rooms.
|
||||
* @property type The type of the foreground.
|
||||
*/
|
||||
@Serializable(SetForegroundEvent.Serializer::class)
|
||||
@KeepGeneratedSerializer
|
||||
@SerialName("SetForeground")
|
||||
public data class SetForegroundEvent(
|
||||
@Flatten
|
||||
private var type: GroundType.Image,
|
||||
override val rooms: RoomsOrTopLayer = roomsOf(ROOM1),
|
||||
) : ActionEvent(), RoomsOrTopLayerSpecificEvent {
|
||||
override var rooms: RoomsOrTopLayer = roomsOf(ROOM1),
|
||||
) : ActionEvent(), MutableRoomsOrTopLayerSpecificEvent {
|
||||
public object Serializer : KSerializer<SetForegroundEvent> by generatedSerializer().flatten()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import cn.rdlevel.rdkt.core.data.Easing
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Sets the speed of the level. Usually it will affect the speed of the event animations.
|
||||
* @property speed The speed multiplier. 1.0 is the normal speed.
|
||||
* @property duration The time to change to the target speed in beats.
|
||||
* @property ease The easing function to use when changing the speed.
|
||||
*/
|
||||
@Serializable
|
||||
@SerialName("SetSpeed")
|
||||
public data class SetSpeedEvent(
|
||||
|
||||
Reference in New Issue
Block a user