Cleanup
This commit is contained in:
@@ -23,15 +23,12 @@ damageCrWlID :: Damage -> CrWlID -> World -> World
|
|||||||
damageCrWlID dam = \case
|
damageCrWlID dam = \case
|
||||||
NothingID -> id
|
NothingID -> id
|
||||||
CrID cid -> cWorld . lWorld . creatures . ix cid . crDamage .:~ dam
|
CrID cid -> cWorld . lWorld . creatures . ix cid . crDamage .:~ dam
|
||||||
--WlID wlid -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) wlid [dam]
|
|
||||||
WlID wlid -> cWorld . lWorld . wallDamages . at wlid . non mempty .:~ dam
|
WlID wlid -> cWorld . lWorld . wallDamages . at wlid . non mempty .:~ dam
|
||||||
|
|
||||||
damageCrWl :: Damage -> Either Creature Wall -> World -> World
|
damageCrWl :: Damage -> Either Creature Wall -> World -> World
|
||||||
damageCrWl dam = \case
|
damageCrWl dam = \case
|
||||||
Left cr -> damageCrWlID dam (CrID (_crID cr))
|
Left cr -> damageCrWlID dam (CrID (_crID cr))
|
||||||
Right wl -> damageCrWlID dam (WlID (_wlID wl))
|
Right wl -> damageCrWlID dam (WlID (_wlID wl))
|
||||||
--damageCrWl dt (Left cr) = cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ dt
|
|
||||||
--damageCrWl dt (Right wl) = cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) [dt]
|
|
||||||
|
|
||||||
-- could sort for damage amount as well
|
-- could sort for damage amount as well
|
||||||
damageDirection :: [Damage] -> Maybe Float
|
damageDirection :: [Damage] -> Maybe Float
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ wlsHit sp ep
|
|||||||
wlsHitRadial :: Point2 -> Float -> World -> [(Point2, Wall)]
|
wlsHitRadial :: Point2 -> Float -> World -> [(Point2, Wall)]
|
||||||
wlsHitRadial p r = mapMaybe f . wlsNearCirc p r
|
wlsHitRadial p r = mapMaybe f . wlsNearCirc p r
|
||||||
where
|
where
|
||||||
f wl = uncurry (intersectSegSeg p (p -.- r *.* v)) (_wlLine wl) <&> (,wl)
|
f wl = uncurry (intersectSegSeg p (p - r *.* v)) (_wlLine wl) <&> (,wl)
|
||||||
where
|
where
|
||||||
v = normalizeV $ vNormal $ uncurry (-.-) $ _wlLine wl
|
v = normalizeV . vNormal . uncurry (-) $ _wlLine wl
|
||||||
|
|
||||||
crsHitRadial :: Point2 -> Float -> World -> [(Point2, Creature)]
|
crsHitRadial :: Point2 -> Float -> World -> [(Point2, Creature)]
|
||||||
crsHitRadial p r = mapMaybe f . crsNearCirc p r
|
crsHitRadial p r = mapMaybe f . crsNearCirc p r
|
||||||
@@ -108,4 +108,4 @@ crsHitRadial p r = mapMaybe f . crsNearCirc p r
|
|||||||
f cr = do
|
f cr = do
|
||||||
let cp = _crPos cr
|
let cp = _crPos cr
|
||||||
guard $ dist p cp < r + crRad (_crType cr)
|
guard $ dist p cp < r + crRad (_crType cr)
|
||||||
return $ (cp + (1 + crRad (_crType cr)) *.* (cp - p), cr)
|
return (cp + (1 + crRad (_crType cr)) *.* (cp - p), cr)
|
||||||
|
|||||||
Reference in New Issue
Block a user