Ilysa by Example: Light

ctx.Sequence() and ctx.Range() loop over time. ctx.Light() loops over light IDs.

package main
import (
    "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/light"
    "github.com/shasderias/ilysa/timer"
    "github.com/shasderias/ilysa/transform"
)
func main() {
    m, _ := beatsaber.NewMockMap(beatsaber.EnvironmentOrigins, 120, "[]")
    p := ilysa.New(m)

light.NewBasic() returns a basic light (base game). Basic lights (i.e. non-Chroma lights) only have 1 light ID and are therefore not very useful with ctx.Light(). Back lasers in the Origins environment have 4 underlying light IDs, so you can imagine backLasers like so:

1 - [1,2,3,4]

    backLasers := light.NewBasic(p, evt.BackLasers)

transform.Light() accepts a light and one or more transformers, and applies the transformers to the light.

    backLasersDiv := transform.Light(backLasers,

transform.DivideSingle() is a transformer that divides a basic light into its underlying light IDs. You can imagine backLasersDiv like so:

1 - [1]
2 - [2]
3 - [3]
4 - [4]

        transform.DivideSingle(),
    )
    p.Range(timer.Rng(0, 1, 3, ease.Linear), func(ctx context.Context) {
        ctx.Light(backLasersDiv, func(ctx context.LightContext) {

This event will have its light ID set to [1] on the first loop, [2], on the second loop, etc, el.

            ctx.NewRGBLighting(evt.WithLight(evt.LightType(evt.LightRedOn)))
        })
    })
    p.Dump()
}
$ go run light.go
[
    {"_customData":{"_lightID":1},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":2},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":3},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":4},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":1},"_time":0.5,"_type":5,"_value":5},
    {"_customData":{"_lightID":2},"_time":0.5,"_type":5,"_value":5},
    {"_customData":{"_lightID":3},"_time":0.5,"_type":5,"_value":5},
    {"_customData":{"_lightID":4},"_time":0.5,"_type":5,"_value":5},
    
    {"_customData":{"_lightID":1},"_time":1,"_type":5,"_value":5},
    {"_customData":{"_lightID":2},"_time":1,"_type":5,"_value":5},
    {"_customData":{"_lightID":3},"_time":1,"_type":5,"_value":5},
    {"_customData":{"_lightID":4},"_time":1,"_type":5,"_value":5}
]

Next example: Light - Fan.