Make _targetCr an Int id rather than a full creature

This commit is contained in:
2025-10-15 20:09:17 +01:00
parent 57ca53638a
commit 5e6ed1d793
13 changed files with 122 additions and 123 deletions
+9 -6
View File
@@ -2,6 +2,7 @@
module Dodge.Creature.Impulse (impulsiveAIBefore) where
import Data.Maybe
import Linear
import NewInt
import Dodge.Creature.MoveType
@@ -64,12 +65,14 @@ followImpulse cr w imp = case imp of
ArbitraryImpulseFunction f -> crup $ doWdCrCr f w cr
ArbitraryImpulse f -> followImpulse cr w (doCrWdImp f cr w)
ArbitraryImpulseEffect f -> (doCrWdWd f cr, cr)
ImpulseUseTargetCID f -> case cr ^? crIntention . targetCr . _Just of
Just tcr -> followImpulse cr w (doIntImp f $ _crID tcr)
_ -> crup cr
ImpulseUseTarget f -> case cr ^? crIntention . targetCr . _Just of
Just tcr -> followImpulse cr w (doCrImp f tcr)
_ -> crup cr
ImpulseUseTargetCID f -> fromMaybe (crup cr) $ do
i <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix i
return $ followImpulse cr w (doIntImp f $ _crID tcr)
ImpulseUseTarget f -> fromMaybe (crup cr) $ do
i <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix i
return $ followImpulse cr w (doCrImp f tcr)
ImpulseUseAheadPos f -> followImpulse cr w (doP2Imp f (cr ^. crPos . _xy +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
MvForward -> crup $ crMvForward speed (w ^. cWorld . lWorld) cr
MvTurnToward p ->