Smooth out slime splitting
There are probably possible errors from the use of cutPoly
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
--import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Creature.Slime
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Creature.MoveType
|
||||
import Dodge.Base.Collide
|
||||
@@ -233,7 +234,7 @@ updateCalmBee cr cid w
|
||||
mountshakeoff mid = fromMaybe True $ do
|
||||
mcr <- w ^? cWorld . lWorld . creatures . ix mid
|
||||
SlimeCrit {_slimeSplitTimer = x} <- mcr ^? crType
|
||||
return $ x > 0
|
||||
return $ isJust x
|
||||
--sspeed = 0.05
|
||||
sspeed = 5
|
||||
gettarg = do
|
||||
@@ -263,9 +264,13 @@ slimeCritUpdate cid w
|
||||
& cWorld . lWorld . creatures . ix cid .~ mvslime
|
||||
& cWorld . lWorld . creatures . ix cid . crDamage .~ []
|
||||
& tocr %~ doSlimeRadChange
|
||||
& tocr . crType . slimeSplitTimer %~ (max 0 . subtract 1)
|
||||
& tocr . crType . slimeSplitTimer %~ fsst
|
||||
& tocr . crType . slimeEngulfProgress %~ (max 0 . subtract 0.5)
|
||||
where
|
||||
fsst Nothing = Nothing
|
||||
fsst (Just (x,ps))
|
||||
| x > 0 = Just (x-1,ps)
|
||||
| otherwise = Nothing
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
-- v = 0.1 *^ normalize p
|
||||
@@ -327,27 +332,30 @@ splitSlimeCrit p v cr = do
|
||||
mvdir
|
||||
| isLHS p (p+v) cxy = normalize (vNormal v)
|
||||
| otherwise = - normalize (vNormal v)
|
||||
return (cr' & crPos . _xy .~ mp + (r1 + 0.51) *^ mvdir
|
||||
-- & crType . slimeRad .~ r1
|
||||
(ps',qs')
|
||||
| isLHS p (p+v) cxy = (ps,qs)
|
||||
| otherwise = (qs,ps)
|
||||
c1 = cr' & crPos . _xy .~ mp + r1 *^ mvdir
|
||||
& crType . slimeSlime .~ round (r1 ^ (2 :: Int) * 100)
|
||||
& crType . slimeCompression .~ 1 -- rotateV (argV mvdir) (V2 r1 0)
|
||||
& crType . slimeIsCompressing .~ False
|
||||
& crDir .~ argV mvdir
|
||||
,cr' & crPos . _xy .~ mp - (r2 + 0.51) *^ mvdir
|
||||
-- & crType . slimeRad .~ r2
|
||||
c2 = cr' & crPos . _xy .~ mp - r2 *^ mvdir
|
||||
& crType . slimeSlime .~ round (r2^(2::Int) * 100)
|
||||
& crType . slimeCompression .~ 1 -- rotateV (argV (-mvdir)) (V2 r2 0)
|
||||
& crType . slimeIsCompressing .~ False
|
||||
& crDir .~ argV (-mvdir)
|
||||
& crType . slimeEngulfProgress .~ 0
|
||||
c1ps = qs' & each +~ cxy - (mp + r1 *^ mvdir) & each %~ rotateV (- c1 ^. crDir)
|
||||
c2ps = ps' & each +~ cxy - (mp - r2 *^ mvdir) & each %~ rotateV (- c2 ^. crDir)
|
||||
return (c1 & crType . slimeSplitTimer . _Just . _2 .~ polyInPoly (centroid c1ps) c1ps (slimeOutline c1)
|
||||
,c2 & crType . slimeSplitTimer . _Just . _2 .~ polyInPoly (centroid c2ps) c2ps (slimeOutline c2)
|
||||
)
|
||||
where
|
||||
cxy = cr ^. crPos . _xy
|
||||
r = cr ^?! crType . slimeSlime . to slimeToRad
|
||||
cr' = cr & crDamage .~ []
|
||||
& crType . slimeSlimeChange .~ 0
|
||||
& crType . slimeSplitTimer .~ 10
|
||||
& crType . slimeSplitTimer .~ Just (10, mempty)
|
||||
& crType . slimeIsCompressing .~ False
|
||||
& crType . slimeCompression .~ 1 -- rotateV (argV mvdir) (V2 r1 0)
|
||||
(ps,qs) = cutPoly (p-cxy) (p+v-cxy) $ slimeOutline cr & each %~ rotateV (cr ^. crDir)
|
||||
|
||||
|
||||
-- h is the height of the segment, ie r - distance to center
|
||||
segmentArea :: Float -> Float -> Float
|
||||
|
||||
Reference in New Issue
Block a user