Refactor crPos to be a V3
This commit is contained in:
+7
-7
@@ -317,7 +317,7 @@ checkTermDist w = fromMaybe w $ do
|
||||
tmid <- w ^? hud . subInventory . termID
|
||||
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
|
||||
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
|
||||
guard $ dist btpos (_crPos $ you w) > 40
|
||||
guard $ dist btpos ( you w ^. crPos . _xy) > 40
|
||||
return $ w & hud . subInventory .~ NoSubInventory
|
||||
|
||||
updateMouseContext :: Config -> Universe -> Universe
|
||||
@@ -505,7 +505,7 @@ updateCreatureSoundPositions w =
|
||||
$ _playingSounds w
|
||||
where
|
||||
insertSound w' k s = w' & toPlaySounds %~ M.insertWith (const id) k s
|
||||
updateSound (CrMouth cid) s = case w ^? cWorld . lWorld . creatures . ix cid . crPos of
|
||||
updateSound (CrMouth cid) s = case w ^? cWorld . lWorld . creatures . ix cid . crPos . _xy of
|
||||
Just p -> Just s{_soundPos = p, _soundAngDist = Just (soundAngle p w, 0)}
|
||||
Nothing -> Just s{_soundTime = Just 0}
|
||||
updateSound _ _ = Nothing
|
||||
@@ -846,11 +846,11 @@ dustSpringVel a v b
|
||||
|
||||
simpleCrSprings :: World -> World
|
||||
simpleCrSprings w = IM.foldl' (flip crSpring) w
|
||||
$ IM.filter (\cr -> _crZ cr >= 0) $ w ^. cWorld . lWorld . creatures
|
||||
$ IM.filter (\cr -> cr ^. crPos . _z >= 0) $ w ^. cWorld . lWorld . creatures
|
||||
|
||||
-- note that this may in rare cases not push creatures away from each other
|
||||
crSpring :: Creature -> World -> World
|
||||
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (_crPos c) w
|
||||
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w
|
||||
|
||||
crCrSpring :: Creature -> Creature -> World -> World
|
||||
crCrSpring c1 c2
|
||||
@@ -859,13 +859,13 @@ crCrSpring c1 c2
|
||||
| diff >= comRad = id
|
||||
| otherwise =
|
||||
cWorld . lWorld . creatures
|
||||
%~ ( over (ix id1 . crPos) (+.+ overlap1)
|
||||
. over (ix id2 . crPos) (-.- overlap2)
|
||||
%~ ( over (ix id1 . crPos . _xy) (+.+ overlap1)
|
||||
. over (ix id2 . crPos . _xy) (-.- overlap2)
|
||||
)
|
||||
where
|
||||
id1 = _crID c1
|
||||
id2 = _crID c2
|
||||
vec = _crPos c1 -.- _crPos c2
|
||||
vec = c1 ^. crPos . _xy -.- c2 ^. crPos . _xy
|
||||
diff = magV vec
|
||||
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
|
||||
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec
|
||||
|
||||
Reference in New Issue
Block a user