2023-06-02 18:35:28 +00:00
|
|
|
package funkin.play.event;
|
|
|
|
|
|
|
|
import flixel.tweens.FlxTween;
|
|
|
|
import flixel.FlxCamera;
|
|
|
|
import flixel.tweens.FlxEase;
|
2023-09-08 21:46:44 +00:00
|
|
|
// Data from the chart
|
|
|
|
import funkin.data.song.SongData;
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
|
|
|
// Data from the event schema
|
2023-06-02 18:35:28 +00:00
|
|
|
import funkin.play.event.SongEvent;
|
2024-01-04 02:10:14 +00:00
|
|
|
import funkin.data.event.SongEventSchema;
|
|
|
|
import funkin.data.event.SongEventSchema.SongEventFieldType;
|
2023-06-02 18:35:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class represents a handler for configuring camera bop intensity and rate.
|
2023-07-13 05:13:26 +00:00
|
|
|
*
|
2023-06-02 18:35:28 +00:00
|
|
|
* Example: Bop the camera twice as hard, once per beat (rather than once every four beats).
|
|
|
|
* ```
|
|
|
|
* {
|
|
|
|
* 'e': 'SetCameraBop',
|
|
|
|
* 'v': {
|
|
|
|
* 'intensity': 2.0,
|
|
|
|
* 'rate': 1,
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
2023-07-13 05:13:26 +00:00
|
|
|
*
|
2023-06-02 18:35:28 +00:00
|
|
|
* Example: Reset the camera bop to default values.
|
|
|
|
* ```
|
|
|
|
* {
|
|
|
|
* 'e': 'SetCameraBop',
|
|
|
|
* 'v': {}
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
class SetCameraBopSongEvent extends SongEvent
|
|
|
|
{
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super('SetCameraBop');
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function handleEvent(data:SongEventData):Void
|
|
|
|
{
|
|
|
|
// Does nothing if there is no PlayState camera or stage.
|
|
|
|
if (PlayState.instance == null) return;
|
|
|
|
|
|
|
|
var rate:Null<Int> = data.getInt('rate');
|
|
|
|
if (rate == null) rate = Constants.DEFAULT_ZOOM_RATE;
|
|
|
|
var intensity:Null<Float> = data.getFloat('intensity');
|
|
|
|
if (intensity == null) intensity = 1.0;
|
|
|
|
|
|
|
|
PlayState.instance.cameraZoomIntensity = Constants.DEFAULT_ZOOM_INTENSITY * intensity;
|
|
|
|
PlayState.instance.hudCameraZoomIntensity = Constants.DEFAULT_ZOOM_INTENSITY * intensity * 2.0;
|
|
|
|
PlayState.instance.cameraZoomRate = rate;
|
|
|
|
trace('Set camera zoom rate to ${PlayState.instance.cameraZoomRate}');
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function getTitle():String
|
|
|
|
{
|
|
|
|
return 'Set Camera Bop';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ```
|
|
|
|
* {
|
|
|
|
* 'intensity': FLOAT, // Zoom amount
|
|
|
|
* 'rate': INT, // Zoom rate (beats/zoom)
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
* @return SongEventSchema
|
|
|
|
*/
|
|
|
|
public override function getEventSchema():SongEventSchema
|
|
|
|
{
|
2024-01-04 02:10:14 +00:00
|
|
|
return new SongEventSchema([
|
2023-06-02 18:35:28 +00:00
|
|
|
{
|
|
|
|
name: 'intensity',
|
|
|
|
title: 'Intensity',
|
|
|
|
defaultValue: 1.0,
|
|
|
|
step: 0.1,
|
2024-01-27 01:51:36 +00:00
|
|
|
type: SongEventFieldType.FLOAT,
|
|
|
|
units: 'x'
|
2023-06-02 18:35:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'rate',
|
2024-01-27 01:51:36 +00:00
|
|
|
title: 'Rate',
|
2023-06-02 18:35:28 +00:00
|
|
|
defaultValue: 4,
|
|
|
|
step: 1,
|
|
|
|
type: SongEventFieldType.INTEGER,
|
2024-01-27 01:51:36 +00:00
|
|
|
units: 'beats/zoom'
|
2023-06-02 18:35:28 +00:00
|
|
|
}
|
2024-01-04 02:10:14 +00:00
|
|
|
]);
|
2023-06-02 18:35:28 +00:00
|
|
|
}
|
|
|
|
}
|