Skip to content

Commit

Permalink
Renaming instances of FrameContext to Context
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 12, 2024
1 parent ba1d3d7 commit 3334830
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final case class JobMarket[Model](id: SubSystemId, availableJobs: List[Job]) ext
private given CanEqual[Option[Job], Option[Job]] = CanEqual.derived

def update(
frameContext: SubSystemContext[ReferenceData],
context: SubSystemContext[ReferenceData],
jobs: List[Job]
): JobMarketEvent => Outcome[List[Job]] = {
case JobMarketEvent.Post(job) =>
Expand All @@ -57,7 +57,7 @@ final case class JobMarket[Model](id: SubSystemId, availableJobs: List[Job]) ext
Outcome(jobs)
}

def present(frameContext: SubSystemContext[ReferenceData], jobs: List[Job]): Outcome[SceneUpdateFragment] =
def present(context: SubSystemContext[ReferenceData], jobs: List[Job]): Outcome[SceneUpdateFragment] =
Outcome(SceneUpdateFragment.empty)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class AssetBundleLoader[Model] extends SubSystem[Model]:
private given CanEqual[Option[Set[AssetType]], Option[Set[AssetType]]] = CanEqual.derived

def update(
frameContext: SubSystemContext[ReferenceData],
context: SubSystemContext[ReferenceData],
tracker: AssetBundleTracker
): GlobalEvent => Outcome[AssetBundleTracker] =
// Asset Bundle Loader Commands
Expand Down Expand Up @@ -76,7 +76,7 @@ final class AssetBundleLoader[Model] extends SubSystem[Model]:
Outcome(tracker)

def present(
frameContext: SubSystemContext[ReferenceData],
context: SubSystemContext[ReferenceData],
model: AssetBundleTracker
): Outcome[SceneUpdateFragment] =
Outcome(SceneUpdateFragment.empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ final case class Automata[Model](
private given CanEqual[Option[Int], Option[Int]] = CanEqual.derived

def update(
frameContext: SubSystemContext[ReferenceData],
context: SubSystemContext[ReferenceData],
state: AutomataState
): AutomataEvent => Outcome[AutomataState] =
case Spawn(key, position, lifeSpan, payload) if key == poolKey =>
val spawned =
SpawnedAutomaton(
automaton.node.giveNode(state.totalSpawned, frameContext.dice),
automaton.node.giveNode(state.totalSpawned, context.dice),
automaton.modifier,
automaton.onCull,
new AutomatonSeedValues(
position,
frameContext.time.running,
context.time.running,
lifeSpan.getOrElse(automaton.lifespan),
frameContext.dice.roll,
context.dice.roll,
payload
)
)
Expand Down Expand Up @@ -108,21 +108,21 @@ final case class Automata[Model](

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

Outcome(
state.copy(
pool = state.pool.filter(_.isAlive(frameContext.time.running))
pool = state.pool.filter(_.isAlive(context.time.running))
),
Batch(cullEvents)
)

case _ =>
Outcome(state)

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

Outcome(
SceneUpdateFragment(
Expand Down
6 changes: 3 additions & 3 deletions indigo/indigo/src/main/scala/indigo/scenes/SceneContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import indigo.shared.scenegraph.SceneNode
import indigo.shared.time.GameTime
import indigo.shared.time.Seconds

/** SceneContext is a Scene specific equivalent of `FrameContext`, and exposes all of the fields and methods or a normal
* `FrameContext` object. It adds information about the scene currently running.
/** SceneContext is a Scene specific equivalent of `Context`, and exposes all of the fields and methods of a normal
* `Context` object. It adds information about the scene currently running.
*
* @param sceneName
* The name of the current scene.
* @param sceneStartTime
* The time that the current scene was entered.
* @param frameContext
* @param context
* The normal frame context object that all other fields delegate to.
*/
final class SceneContext[StartUpData](
Expand Down
11 changes: 5 additions & 6 deletions indigo/indigo/src/main/scala/indigo/shared/dice/Dice.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import scala.annotation.tailrec

/** The Dice primitive supplies a consistent way to get psuedo-random values into your game.
*
* A dice instance can be found in the FrameContext object with 'max int' sides, and every frame the dice's seed value
* is set to the current running time of the game in milliseconds.
* A dice instance can be found in the Context object with 'max int' sides, and every frame the dice's seed value is
* set to the current running time of the game in milliseconds.
*
* Dice also serve as a handy proxy to a number of functions found on a normal `Random` instance, like alphanumeric,
* but with a predicatable seed.
*/
trait Dice:

/** The seed value of the dice. The dice supplied in the `FrameContext` has the seed set to the current running time
* of the game in milliseconds.
/** The seed value of the dice. The dice supplied in the `Context` has the seed set to the current running time of the
* game in milliseconds.
*
* If the seed value is 0, it is replaced with the `DefaultSeed` value in order for the underlying PRNG to work
* correctly.
Expand Down Expand Up @@ -102,8 +102,7 @@ object Dice:
def fromMillis(time: Millis): Dice =
Sides.MaxInt(time.toLong)

/** Construct a 'max int' sided dice from a given seed value. This is the default dice presented by the
* `FrameContext`.
/** Construct a 'max int' sided dice from a given seed value. This is the default dice presented by the `Context`.
*
* The implementation of this method uses the Xorshift algorithm to generate random numbers, which has a problem: A
* seed value of 0 will produce a value of 0. This is a known issue with the algorithm, and while it is not a bug, it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import indigo.shared.scenegraph.SceneNode
import indigo.shared.time.GameTime
import indigo.shared.time.Seconds

/** Similar to [FrameContext] but without access to start up data. The SubSystemContext is the context in which the
* current frame will be processed. In includes values that are unique to this frame, and also globally available
* services.
/** Similar to `Context` but without access to start up data. The SubSystemContext is the context in which the current
* frame will be processed. In includes values that are unique to this frame, and also globally available services.
*
* @param gameTime
* A sampled instance of time that you should use everywhere that you need a time value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class SubSystemsRegister[Model] {

// @SuppressWarnings(Array("scalafix:DisableSyntax.asInstanceOf"))
def update(
frameContext: SubSystemContext[Unit],
context: SubSystemContext[Unit],
gameModel: Model,
globalEvents: js.Array[GlobalEvent]
): Outcome[SubSystemsRegister[Model]] = {
Expand All @@ -67,7 +67,7 @@ final class SubSystemsRegister[Model] {
filteredEvents.foldLeft(Outcome(model)) { (acc, e) =>
acc.flatMap { m =>
subSystem.update(
frameContext.copy(reference = subSystem.reference(gameModel)),
context.copy(reference = subSystem.reference(gameModel)),
m
)(e)
}
Expand All @@ -88,11 +88,11 @@ final class SubSystemsRegister[Model] {
}

// @SuppressWarnings(Array("scalafix:DisableSyntax.asInstanceOf"))
def present(frameContext: SubSystemContext[Unit], gameModel: Model): Outcome[SceneUpdateFragment] =
def present(context: SubSystemContext[Unit], gameModel: Model): Outcome[SceneUpdateFragment] =
registeredSubSystems
.map { rss =>
rss.subSystem.present(
frameContext.copy(reference = rss.subSystem.reference(gameModel)),
context.copy(reference = rss.subSystem.reference(gameModel)),
stateMap(rss.id).asInstanceOf[rss.subSystem.SubSystemModel]
)
}
Expand Down

0 comments on commit 3334830

Please sign in to comment.