appliedSystem.module
This package holds more than this page lists. See all of its files in its world.
README.md
appliedSystem
What a scene-wide effect held by its asset needs beside the applicable gate:
which application of the asset is in force, the asset's live values, a system
API's write landed where the value takes effect, and the runtime hands on a
system whose render feature asset is self-contained.
local AppliedSystem = require("@builtin::modules.appliedSystem")
-- From a type's own apply / setEnabled / drop:
AppliedSystem.track(self, owner, opts) -- on/off, the owner's writer, newest statement
AppliedSystem.trackEnabled(self, owner, enabled)
AppliedSystem.untrack(self, owner)
AppliedSystem.inForce(ref) -- the owner that last stated something new and is on
AppliedSystem.applications(ref) -- { { owner, enabled, stamp } }
AppliedSystem.values(ref, owner) -- own values, then live values, then what the owner stated
AppliedSystem.setLive(ref, { density = 0.03 })
AppliedSystem.resetLive(ref)
AppliedSystem.write(ref, { density = 0.02 }, "fog.set")
write sets the live value of a parameter the application written through does
not state, and writes one it does state through that owner's writer, the
opts.write it handed apply; a stated parameter whose owner handed no writer
raises naming the API, the parameter and the owner. opts.owner names the
application written through, else the one in force; opts.owned sends every
parameter through the writer. Live values are shared by every application of
the asset for the session mode and go with its runtime state; changing them
applies every application of the asset again.
A system's module and component:
local system = AppliedSystem.module({
identity = "<render feature identity>",
api = "<system>.set",
owner = "<system>.api",
changes = function(o, _current) return { intensity = o.intensity } end,
drawing = function(values) return (values.intensity or 0) > 0 end,
})
system.set({ intensity = 0.5 }) -- lands where the value takes effect
local life = AppliedSystem.component({
identity = "<render feature identity>",
name = "<Component>",
fields = { "intensity" },
values = function(p) return { intensity = p.intensity } end,
})
function awake() life.awake(public) end
function onDestroy() life.onDestroy(public) end
set applies the asset for the module's own owner when nothing applies it, and
lands each value with write. valuesOf(ref) reads the values in force.