More strictifiiiying

This commit is contained in:
2021-07-30 01:25:11 +02:00
parent 2d8b27746c
commit 7b7fd302d8
37 changed files with 459 additions and 448 deletions
+2 -2
View File
@@ -68,8 +68,8 @@ blinkAction cr w = soundOnce teleSound
where
distR = 120
distortionBulge =
[(p3,p3 +.+ (distR,0), p3 +.+ (0,distR),0.1)
,(cpos,cpos +.+ (distR,0), cpos +.+ (0,distR),1.9)
[(p3,p3 +.+ (V2 distR 0), p3 +.+ (V2 0 distR),0.1)
,(cpos,cpos +.+ (V2 distR 0), cpos +.+ (V2 0 distR),1.9)
]
cid = _crID cr
p1 = mouseWorldPos w
+5 -5
View File
@@ -17,7 +17,7 @@ import Dodge.WorldEvent.Sound
import Dodge.Creature.Update hiding (CRUpdate)
import Picture
import qualified IntMapHelp as IM
--import Geometry
import Geometry.Data
import Geometry.Vector3D
import Polyhedra
@@ -36,7 +36,7 @@ lamp h = defaultInanimate
}
lampPic :: Float -> Picture
lampPic h = pictures
[ setLayer 0 $ pictures . map (helpPoly3D . map ((, blue) . (-.-.- (2.5,2.5,0)))) $ boxXYZ 5 5 (h-1)
[ setLayer 0 $ pictures . map (helpPoly3D . map ((, blue) . (-.-.- (V3 2.5 2.5 0)))) $ boxXYZ 5 5 (h-1)
, setLayer 1 $ setDepth h $ color white $ circleSolid 3
]
@@ -44,8 +44,8 @@ initialiseLamp :: Float -> CRUpdate
initialiseLamp h w (f,g) cr = ( (addLS . f , g), Just $ cr & crUpdate .~ updateLamp h i)
where
i = IM.newKey $ _lightSources $ f w -- to give different lights different keys
addLS = over lightSources (IM.insert i (lightAt (x,y,h) i))
(x,y) = _crPos cr
addLS = over lightSources (IM.insert i (lightAt (V3 x y h) i))
(V2 x y) = _crPos cr
updateLamp :: Float -> Int -> CRUpdate
updateLamp h i = unrandUpdate handleLS internalUpdate
@@ -56,7 +56,7 @@ updateLamp h i = unrandUpdate handleLS internalUpdate
| otherwise = w & lightSources . ix i . lsPos .~ f cPos
where
cPos = _crPos cr
f (x,y) = (x,y,h)
f (V2 x y) = (V3 x y h)
internalUpdate cr
| _crHP cr < 0 = Nothing
| otherwise = Just $ doDamage cr
+2 -2
View File
@@ -16,7 +16,7 @@ import Dodge.Creature.State
--import Dodge.Creature.State.Data
import Dodge.Item.Weapon.Launcher
--import Dodge.Item.Consumable
--import Geometry
import Geometry.Data
import Picture
import qualified Data.IntMap.Strict as IM
@@ -37,7 +37,7 @@ launcherCrit = defaultCreature
>=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
(\ _ -> crActionPlan . crStrategy .~ WatchAndWait)
, _crActionPlan = ActionPlan
{ _crImpulse = []
+3 -3
View File
@@ -45,7 +45,7 @@ ltAutoCrit = defaultCreature
>=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
(\ _ -> crActionPlan . crStrategy .~ WatchAndWait)
, _crActionPlan = ActionPlan
{ _crImpulse = []
@@ -64,9 +64,9 @@ chooseMovement cr w
| dist cpos p > 200 = DoImpulses [UseItem,TurnToward p 0.05 , MoveForward 3]
| dist cpos p < 80 = DoImpulses [UseItem,TurnToward p 0.05, MoveForward (-3) ]
| errorAngleVV 22 (p' -.- cpos) (unitVectorAtAngle (_crDir cr)) < 0.4
= DoImpulses [UseItem,TurnToward p' 0.01, Move (0,3)]
= DoImpulses [UseItem,TurnToward p' 0.01, Move (V2 0 3)]
| otherwise
= DoImpulses [UseItem,TurnToward p' 0.05, Move (0,3)]
= DoImpulses [UseItem,TurnToward p' 0.05, Move (V2 0 3)]
where
cpos = _crPos cr
tcr = _creatures w IM.! 0
+5 -5
View File
@@ -39,7 +39,7 @@ pistolCrit = defaultCreature
>=> doStrategyActionsR
>=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
( \ _ -> crActionPlan . crStrategy .~ WatchAndWait )
, _crActionPlan = ActionPlan
{ _crImpulse = []
@@ -81,19 +81,19 @@ chooseMovement' cr w = takeOneWeighted [chargeProb,retreatProb,strafeProb,strafe
`DoImpulsesAlongside`
3
`DoReplicate`
ImpulsesList (replicate 9 [Move (3,0)] ++ [[Move (3,0),UseItem]])
ImpulsesList (replicate 9 [Move (V2 3 0)] ++ [[Move (V2 3 0),UseItem]])
strafeLeftActions =
DoImpulses [TurnToward yposr (2*pi)]
`DoActionThen`
3
`DoReplicate`
ImpulsesList (replicate 9 [Move (0,3)] ++ [[Move (0,3),UseItem]])
ImpulsesList (replicate 9 [Move (V2 0 3)] ++ [[Move (V2 0 3),UseItem]])
strafeRightActions =
DoImpulses [TurnToward yposl (2*pi)]
`DoActionThen`
3
`DoReplicate`
ImpulsesList (replicate 9 [Move (0,-3)] ++ [[Move (0,-3),UseItem]])
ImpulsesList (replicate 9 [Move (V2 (0) (-3))] ++ [[Move (V2 (0) (-3)),UseItem]])
yposl = ypos -.- 100 *.* vNormal (normalizeV $ ypos -.- cpos)
yposr = ypos +.+ 100 *.* vNormal (normalizeV $ ypos -.- cpos)
@@ -103,7 +103,7 @@ retreatActions tcr cr =
`DoImpulsesAlongside`
3
`DoReplicate`
ImpulsesList (replicate 9 [Move (-3,0)] ++ [[UseItem]])
ImpulsesList (replicate 9 [Move (V2 (-3) (0))] ++ [[UseItem]])
where
cpos = _crPos cr
tpos = _crPos tcr
+7 -7
View File
@@ -11,7 +11,7 @@ import Dodge.Creature.Rationality
import Dodge.Creature.AlertLevel
--import Dodge.Creature.State
--import Dodge.Creature.State.Data
--import Geometry
import Geometry.Data
--import Picture
--import Dodge.RandomHelp
@@ -39,7 +39,7 @@ sentinelAI = sentinelExtraWatchUpdate
DoImpulses [ChangeStrategy WatchAndWait]
, AimAtCloseSlow
{ _targetID = tcid
, _targetSeenAt = (0,0) -- hack
, _targetSeenAt = (V2 0 0) -- hack
, _aimSpeed = 0.2
, _slowAimSpeed = 0.01
, _slowAimAngle = pi/8
@@ -66,13 +66,13 @@ sentinelFireType f = performActionsR
>=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
(onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
(\ _ -> crActionPlan . crStrategy .~ WatchAndWait)
where
drawwp = DoActionIfElse NoAction crIsAiming (DoActionThen drawWeapon (WaitThen 50 NoAction))
aiming = AimAtCloseSlow
{ _targetID = 0
, _targetSeenAt = (0,0) -- hack
, _targetSeenAt = (V2 0 0) -- hack
, _aimSpeed = 0.2
, _slowAimSpeed = 0.01
, _slowAimAngle = pi/8
@@ -89,7 +89,7 @@ sentinelExtraWatchUpdate xs = performActionsR
>=> doStrategyActionsR
-- >=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
(\ _ -> crActionPlan . crStrategy .~ WatchAndWait)
@@ -104,7 +104,7 @@ shootAtAdvance tcid =
DoImpulses [ChangeStrategy WatchAndWait]
, AimAtCloseSlow
{ _targetID = tcid
, _targetSeenAt = (0,0) -- hack
, _targetSeenAt = (V2 0 0) -- hack
, _aimSpeed = 0.2
, _slowAimSpeed = 0.01
, _slowAimAngle = pi/8
@@ -125,7 +125,7 @@ shootAtWhileContinueTime tcid _ _ = StrategyActions (ShootAt tcid)
DoImpulses [ChangeStrategy WatchAndWait]
, AimAtCloseSlow
{ _targetID = tcid
, _targetSeenAt = (0,0) -- hack
, _targetSeenAt = (V2 0 0) -- hack
, _aimSpeed = 0.2
, _slowAimSpeed = 0.01
, _slowAimAngle = pi/8
+1 -1
View File
@@ -44,7 +44,7 @@ spreadGunCrit = defaultCreature
>=> doStrategyActionsR
>=> reloadOverrideR
>=> targetYouWhenCognizantR
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
>=> overrideInternalR (onBoth (&&) crHasTarget (crStratConMatches (GetTo (V2 0 0))))
(\ _ -> crActionPlan . crStrategy .~ WatchAndWait)
, _crActionPlan = ActionPlan
{ _crImpulse = []
+2 -2
View File
@@ -58,7 +58,7 @@ stateUpdate u w (f,g) cr =
. dropByState cr
--crBeforeDeath = colCrWall w cr
addCorpse = IM.insertNewKey
$ uncurry translate (_crOldPos cr)
$ uncurryV translate (_crOldPos cr)
$ rotate (_crDir cr)
(_crCorpse cr)
-- | Drop items according to the creature state.
@@ -78,7 +78,7 @@ Given a creature and a velocity, applies friction to that creature and evaluates
velocity to carry across frames.
-}
crFriction :: Creature -> Point2 -> Point2
crFriction _ _ = (0,0)
crFriction _ _ = (V2 0 0)
doDamage :: Creature -> Creature
doDamage cr = set (crState . crDamage) []
+9 -9
View File
@@ -37,7 +37,7 @@ wasdWithAiming w speed i cr
| otherwise = theTurn $ theMovement cr
where
theMovement
| movDir == (0,0) = id
| movDir == (V2 0 0) = id
| otherwise = crMvAbsolute (speed *.* movAbs) . set crMvDir dir
theTurn cr' = creatureTurnTowardDir (_crMvDir cr') 0.2 cr'
movDir = wasdDir w
@@ -53,19 +53,19 @@ wasdWithAiming w speed i cr
wasdM :: World -> SDL.Scancode -> Point2
wasdM w scancode
| scancode == moveUpKey (_keyConfig w) = ( 0, 1)
| scancode == moveDownKey (_keyConfig w) = ( 0,-1)
| scancode == moveRightKey (_keyConfig w) = ( 1, 0)
| scancode == moveLeftKey (_keyConfig w) = (-1, 0)
wasdM _ _ = (0,0)
| scancode == moveUpKey (_keyConfig w) = ( V2 (0) ( 1))
| scancode == moveDownKey (_keyConfig w) = (V2 ( 0) (-1))
| scancode == moveRightKey (_keyConfig w) = (V2 ( 1) ( 0))
| scancode == moveLeftKey (_keyConfig w) = (V2 (-1) ( 0))
wasdM _ _ = (V2 0 0)
wasdDir :: World -> Point2
wasdDir w = foldr ((+.+) . wasdM w) (0,0) $ _keys w
wasdDir w = foldr ((+.+) . wasdM w) (V2 0 0) $ _keys w
wasdComp :: S.Set SDL.Scancode -> World -> (Point2,Maybe Float)
wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (0,0) ks
wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (V2 0 0) ks
where
f (0,0) = ((0,0), Nothing)
f (V2 0 0) = ((V2 0 0), Nothing)
f p = (errorNormalizeV 46 p, Just $ argV p)
{- | Set posture according to mouse presses. -}