Slime crit collisions
This commit is contained in:
@@ -69,6 +69,7 @@ slimeCrit = defaultCreature
|
|||||||
& crType .~ SlimeCrit 40 (V2 30 0) False True
|
& crType .~ SlimeCrit 40 (V2 30 0) False True
|
||||||
& crFaction .~ ColorFaction (light green)
|
& crFaction .~ ColorFaction (light green)
|
||||||
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
||||||
|
& crActionPlan .~ SlimeIntelligence
|
||||||
|
|
||||||
hoverCrit :: Creature
|
hoverCrit :: Creature
|
||||||
hoverCrit =
|
hoverCrit =
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ drawCreature w m cr = translateSP (_crPos cr) . fallrot . rotateSP (_crDir cr) $
|
|||||||
_ -> id
|
_ -> id
|
||||||
|
|
||||||
drawSlimeCrit :: Creature -> Shape
|
drawSlimeCrit :: Creature -> Shape
|
||||||
drawSlimeCrit cr = colorSH green $ upperPrismPolyHalf Medium Undesired r $ polyCirc 6 r
|
drawSlimeCrit cr = colorSH green $ upperPrismPolyHalf Medium Typical r $ polyCirc 6 r
|
||||||
& each %~ scaleAlong d s
|
& each %~ scaleAlong d s
|
||||||
& each %~ scaleAlong (vNormal d) (1 / s)
|
& each %~ scaleAlong (vNormal d) (1 / s)
|
||||||
& each %~ rotateV (-cr ^. crDir)
|
& each %~ rotateV (-cr ^. crDir)
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ isAnimate :: Creature -> Bool
|
|||||||
{-# INLINE isAnimate #-}
|
{-# INLINE isAnimate #-}
|
||||||
isAnimate cr = case _crActionPlan cr of
|
isAnimate cr = case _crActionPlan cr of
|
||||||
Inanimate -> False
|
Inanimate -> False
|
||||||
_ -> True
|
SlimeIntelligence -> False
|
||||||
|
ActionPlan{} -> True
|
||||||
|
|
||||||
hasAutoDoorBody :: Creature -> Bool
|
hasAutoDoorBody :: Creature -> Bool
|
||||||
hasAutoDoorBody cr = case cr ^. crHP of
|
hasAutoDoorBody cr = case cr ^. crHP of
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import Sound.Data
|
|||||||
|
|
||||||
data ActionPlan
|
data ActionPlan
|
||||||
= Inanimate
|
= Inanimate
|
||||||
|
| SlimeIntelligence
|
||||||
| ActionPlan
|
| ActionPlan
|
||||||
{ -- _apImpulse :: [Impulse] -- done per frame
|
{ -- _apImpulse :: [Impulse] -- done per frame
|
||||||
_apAction :: Action -- updated per frame, likely persist across frames
|
_apAction :: Action -- updated per frame, likely persist across frames
|
||||||
|
|||||||
+16
-1
@@ -1002,7 +1002,13 @@ crCrSpring c1 c2
|
|||||||
| diffheight = id
|
| diffheight = id
|
||||||
| SlimeCrit{} <- c1 ^. crType
|
| SlimeCrit{} <- c1 ^. crType
|
||||||
, SlimeCrit{} <- c2 ^. crType
|
, SlimeCrit{} <- c2 ^. crType
|
||||||
, id2 > id1 = fuseSlimes c1 c2
|
, id2 > id1
|
||||||
|
, distance xy1 xy2 < abs (r1 - r2) + 1 = fuseSlimes c1 c2
|
||||||
|
| SlimeCrit{} <- c1 ^. crType =
|
||||||
|
--cWorld . lWorld . creatures %~ (rolap c1 c2 . rolap' c2 c1)
|
||||||
|
cWorld . lWorld . creatures %~ (rolap . rolap')
|
||||||
|
| SlimeCrit{} <- c2 ^. crType = id
|
||||||
|
-- cWorld . lWorld . creatures %~ ( rolap c1 c2 . rolap' c2 c1)
|
||||||
| otherwise = cWorld . lWorld . creatures %~ ( olap c1 c2 . olap' c2 c1)
|
| otherwise = cWorld . lWorld . creatures %~ ( olap c1 c2 . olap' c2 c1)
|
||||||
where
|
where
|
||||||
z c = c ^. crPos . _z
|
z c = c ^. crPos . _z
|
||||||
@@ -1013,13 +1019,22 @@ crCrSpring c1 c2
|
|||||||
return $ z c1 > h2 || z c2 > h1
|
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
|
||||||
olap' a b = ix (a ^. crID) . crPos . _xy -~ overlap b
|
olap' a b = ix (a ^. crID) . crPos . _xy -~ overlap b
|
||||||
|
suckx = min 1 (2 * (1 - distance xy1 xy2 / (r1 + r2)))
|
||||||
|
rolap = ix id1 . crPos . _xy +~ (2*m2 / (m1+m2)) *^ normalize (xy2 - xy1)
|
||||||
|
rolap' = ix id2 . crPos . _xy +~ (suckx * 1.5*m1 / (m1+m2)) *^ normalize (xy1 - xy2)
|
||||||
id1 = _crID c1
|
id1 = _crID c1
|
||||||
id2 = _crID c2
|
id2 = _crID c2
|
||||||
|
xy1 = c1 ^. crPos . _xy
|
||||||
|
xy2 = c2 ^. crPos . _xy
|
||||||
vec = c1 ^. crPos . _xy - c2 ^. crPos . _xy
|
vec = c1 ^. crPos . _xy - c2 ^. crPos . _xy
|
||||||
diff = magV vec
|
diff = magV vec
|
||||||
|
r1 = crRad (c1 ^. crType)
|
||||||
|
r2 = crRad (c2 ^. crType)
|
||||||
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
|
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
|
||||||
overlap c = ((comRad - diff) * crMass (_crType c) * 0.5 / massT) *^ signorm vec
|
overlap c = ((comRad - diff) * crMass (_crType c) * 0.5 / massT) *^ signorm vec
|
||||||
massT = crMass (_crType c1) + crMass (_crType c2)
|
massT = crMass (_crType c1) + crMass (_crType c2)
|
||||||
|
m1 = crMass $ c1 ^. crType
|
||||||
|
m2 = crMass $ c2 ^. crType
|
||||||
|
|
||||||
fuseSlimes :: Creature -> Creature -> World -> World
|
fuseSlimes :: Creature -> Creature -> World -> World
|
||||||
fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix i1 .~ c)
|
fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix i1 .~ c)
|
||||||
|
|||||||
Reference in New Issue
Block a user