@@ -19,12 +19,12 @@ package com.lambda.interaction.construction.simulation
1919
2020import com.lambda.context.Automated
2121import com.lambda.context.AutomatedSafeContext
22- import com.lambda.interaction.construction.simulation.processing.PreProcessingData
23- import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.getProcessingInfo
24- import com.lambda.interaction.construction.simulation.result.BuildResult
2522import com.lambda.interaction.construction.simulation.checks.BasicChecker.hasBasicRequirements
2623import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak
2724import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction
25+ import com.lambda.interaction.construction.simulation.processing.PreProcessingData
26+ import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.getProcessingInfo
27+ import com.lambda.interaction.construction.simulation.result.BuildResult
2828import com.lambda.interaction.construction.verify.TargetState
2929import com.lambda.util.BlockUtils.matches
3030import net.minecraft.block.BlockState
@@ -68,7 +68,7 @@ interface SimInfo : Automated {
6868 pov,
6969 Stack (),
7070 concurrentResults
71- ).takeIf { it.hasBasicRequirements() }?.sim()
71+ )? .takeIf { it.hasBasicRequirements() }?.sim()
7272
7373 /* *
7474 * Creates a new [SimInfo] using the current [SimInfo]'s [dependencyStack] and [concurrentResults],
@@ -89,7 +89,7 @@ interface SimInfo : Automated {
8989 pov,
9090 Stack <Sim <* >>().apply { addAll(dependencyStack) },
9191 concurrentResults
92- ).takeIf { it.hasBasicRequirements() }?.sim()
92+ )? .takeIf { it.hasBasicRequirements() }?.sim()
9393
9494 @SimDsl
9595 private fun AutomatedSafeContext.getTypedInfo (
@@ -99,31 +99,29 @@ interface SimInfo : Automated {
9999 pov : Vec3d ,
100100 dependencyStack : Stack <Sim <* >>,
101101 concurrentResults : MutableSet <BuildResult >
102- ): SimInfo {
103- if (! targetState.isEmpty()) {
104- getProcessingInfo(state, targetState, pos)?.let { preProcessing ->
105- return object : InteractSimInfo , Automated by this {
106- override val pos = pos
107- override val state = state
108- override val targetState = targetState
109- override val pov = pov
110- override val dependencyStack = dependencyStack
111- override val concurrentResults = concurrentResults
112- override val preProcessing = preProcessing
113- override val expectedState = preProcessing.info.expectedState
114- override val item = preProcessing.info.item
115- override val placing = preProcessing.info.placing
116-
117- context(_: AutomatedSafeContext , _: Sim <* >)
118- override suspend fun sim () = simInteraction()
102+ ): SimInfo ? =
103+ if (! targetState.isEmpty()) {
104+ getProcessingInfo(state, targetState, pos)?.let { preProcessing ->
105+ object : InteractSimInfo , Automated by this {
106+ override val pos = pos
107+ override val state = state
108+ override val targetState = targetState
109+ override val pov = pov
110+ override val dependencyStack = dependencyStack
111+ override val concurrentResults = concurrentResults
112+ override val preProcessing = preProcessing
113+ override val expectedState = preProcessing.info.expectedState
114+ override val item = preProcessing.info.item
115+ override val placing = preProcessing.info.placing
119116
120- override fun AutomatedSafeContext.matchesTarget (state : BlockState , completely : Boolean ) =
121- expectedState.matches(state, if (! completely) preProcessing.info.ignore else emptySet())
122- }
123- }
124- }
117+ context(_: AutomatedSafeContext , _: Sim <* >)
118+ override suspend fun sim () = simInteraction()
125119
126- return object : BreakSimInfo , Automated by this {
120+ override fun AutomatedSafeContext.matchesTarget (state : BlockState , completely : Boolean ) =
121+ expectedState.matches(state, if (! completely) preProcessing.info.ignore else emptySet())
122+ }
123+ }
124+ } else object : BreakSimInfo , Automated by this {
127125 override val pos = pos
128126 override val state = state
129127 override val targetState = targetState
@@ -134,7 +132,6 @@ interface SimInfo : Automated {
134132 context(_: AutomatedSafeContext , _: Sim <* >)
135133 override suspend fun sim () = simBreak()
136134 }
137- }
138135 }
139136}
140137
0 commit comments