Creature springs checks for heights
This commit is contained in:
+9
-2
@@ -975,16 +975,23 @@ canSpring cr =
|
||||
cr ^. crPos . _z >= 0 && case cr ^. crHP of
|
||||
HP{} -> True
|
||||
CrIsCorpse{} -> True
|
||||
CrIsGibs -> False
|
||||
CrIsPitted -> False
|
||||
CrDestroyed{} -> False
|
||||
|
||||
-- should possibly limit how big this can get
|
||||
crCrSpring :: Creature -> Creature -> World -> World
|
||||
crCrSpring c1 c2
|
||||
| id1 == id2 = id
|
||||
| vec == V2 0 0 = id
|
||||
| diff >= comRad = id
|
||||
| diffheight = id
|
||||
| otherwise = cWorld . lWorld . creatures %~ ( olap c1 c2 . olap' c2 c1)
|
||||
where
|
||||
z c = c ^. crPos . _z
|
||||
h c = fmap (+ z c) (crHeight c)
|
||||
diffheight = fromMaybe True $ do
|
||||
h1 <- h c1
|
||||
h2 <- h c2
|
||||
return $ (z c1 > h2 || z c2 > h1)
|
||||
olap a b = ix (a ^. crID) . crPos . _xy +~ overlap b
|
||||
olap' a b = ix (a ^. crID) . crPos . _xy -~ overlap b
|
||||
id1 = _crID c1
|
||||
|
||||
Reference in New Issue
Block a user