Ilysa by Example: Range

Events can also be generated by specifying a range and the events to generate within that range.

package main
import (
    "fmt"
    "github.com/shasderias/ilysa"
    "github.com/shasderias/ilysa/beatsaber"
    "github.com/shasderias/ilysa/context"
    "github.com/shasderias/ilysa/ease"
    "github.com/shasderias/ilysa/evt"
    "github.com/shasderias/ilysa/timer"
)
func main() {
    m, _ := beatsaber.NewMockMap(beatsaber.EnvironmentOrigins, 120, "[]")
    p := ilysa.New(m)

This line specifies a range between 0 and 0.5 beats with 6 beats.

    p.Range(timer.Rng(0, 0.5, 6, ease.Linear), func(ctx context.Context) {
        ctx.NewLighting(
            evt.WithLight(evt.BackLasers),
            evt.WithLightValue(evt.LightBlueFade),
        )

The values available on a ctx.Sequence()’s ctx are also available on on a ctx.Range()’s ctx, although some of the values are not be as useful.

        fmt.Printf("%4.2f %4.2f %1d %4.2f %t\n",
            ctx.B(), ctx.T(), ctx.Ordinal(), ctx.SeqNextBOffset(), ctx.Last())
    })
    p.Dump()
}
$ go run range.go
0.00 0.00 0 0.08 false
0.10 0.20 1 0.08 false
0.20 0.40 2 0.08 false
0.30 0.60 3 0.08 false
0.40 0.80 4 0.08 false
0.50 1.00 5 0.08 true
[
    {"_time":0,"_type":0,"_value":3},
    {"_time":0.1,"_type":0,"_value":3},
    {"_time":0.2,"_type":0,"_value":3},
    {"_time":0.3,"_type":0,"_value":3},
    {"_time":0.4,"_type":0,"_value":3},
    {"_time":0.5,"_type":0,"_value":3}
]

Next example: Sequence and Range.