Skip to content

Commit

Permalink
SubSystemContext should not export frame/services
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 12, 2024
1 parent 3334830 commit 4c4602a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ final case class Automata[Model](
case Spawn(key, position, lifeSpan, payload) if key == poolKey =>
val spawned =
SpawnedAutomaton(
automaton.node.giveNode(state.totalSpawned, context.dice),
automaton.node.giveNode(state.totalSpawned, context.frame.dice),
automaton.modifier,
automaton.onCull,
new AutomatonSeedValues(
position,
context.time.running,
context.frame.time.running,
lifeSpan.getOrElse(automaton.lifespan),
context.dice.roll,
context.frame.dice.roll,
payload
)
)
Expand Down Expand Up @@ -108,12 +108,12 @@ final case class Automata[Model](

case Update(key) if key == poolKey =>
val cullEvents = state.pool
.filterNot(_.isAlive(context.time.running))
.filterNot(_.isAlive(context.frame.time.running))
.flatMap(sa => sa.onCull(sa.seedValues))

Outcome(
state.copy(
pool = state.pool.filter(_.isAlive(context.time.running))
pool = state.pool.filter(_.isAlive(context.frame.time.running))
),
Batch(cullEvents)
)
Expand All @@ -122,7 +122,7 @@ final case class Automata[Model](
Outcome(state)

def present(context: SubSystemContext[ReferenceData], state: AutomataState): Outcome[SceneUpdateFragment] =
val updated = Automata.renderNoLayer(state.pool, context.time)
val updated = Automata.renderNoLayer(state.pool, context.frame.time)

Outcome(
SceneUpdateFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ final case class FPSCounter[Model](
model: FPSCounterState
): GlobalEvent => Outcome[FPSCounterState] = {
case FrameTick =>
if (context.time.running >= (model.lastInterval + Seconds(1)))
if (context.frame.time.running >= (model.lastInterval + Seconds(1)))
Outcome(
model.copy(
fps = decideNextFps(model.frameCountSinceInterval),
lastInterval = context.time.running,
lastInterval = context.frame.time.running,
frameCountSinceInterval = 0
)
)
Expand All @@ -90,7 +90,7 @@ final case class FPSCounter[Model](
.moveTo(model.position + 2)

val size: Rectangle =
context.bounds.measureText(text)
context.services.bounds.measureText(text)

val boxSize =
({ (s: Size) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ final case class SubSystemContext[ReferenceData](
frame: Context.Frame,
services: Context.Services
):
export frame.*
export services.*

def toContext: Context[Unit] =
new Context[Unit]((), frame, services)
Expand Down

0 comments on commit 4c4602a

Please sign in to comment.