Cleanup
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
--import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Creature.Slime
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Creature.MoveType
|
||||
@@ -17,7 +16,6 @@ import qualified IntMapHelp as IM
|
||||
import Data.Maybe
|
||||
import Dodge.Barreloid
|
||||
import Dodge.Base.You
|
||||
-- import Dodge.Base.NewID
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Creature.Picture
|
||||
import Dodge.Creature.State
|
||||
@@ -50,15 +48,11 @@ updateCreature cr
|
||||
| cr ^. crPos . _z < negate 300 = (cWorld . lWorld . creatures . at (cr ^. crID) %~ destroyCreature)
|
||||
. destroyAllInvItems cr
|
||||
| otherwise = case cr ^. crHP of
|
||||
CrIsCorpse{} -> cleardamage . updateCarriage (_crID cr) . damageCorpse (_crID cr) cr
|
||||
CrIsCorpse{} -> cleardamage . updateCarriage (_crID cr) . applyCreatureDamage (_crID cr) cr
|
||||
AvatarDestroyed{} -> id
|
||||
HP{} -> cleardamage . updateLivingCreature cr
|
||||
where
|
||||
cleardamage = tocr . crDamage .~ mempty
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
|
||||
damageCorpse :: Int -> Creature -> World -> World
|
||||
damageCorpse _ cr w = w & applyCreatureDamage (cr ^. crDamage) cr
|
||||
cleardamage = cWorld . lWorld . creatures . ix (cr^.crID) . crDamage .~ mempty
|
||||
|
||||
updateLivingCreature :: Creature -> World -> World
|
||||
updateLivingCreature cr = case cr ^. crType of
|
||||
@@ -108,7 +102,8 @@ updateHiveCrit cr cid w
|
||||
|
||||
updateBeeFromPheremones :: Creature -> Int -> World -> World
|
||||
updateBeeFromPheremones cr cid w
|
||||
| any f (w ^. cWorld . lWorld . beePheremones) = w & cWorld . lWorld . creatures . ix cid . crType . beeAggro .~ 300
|
||||
| any f (w ^. cWorld . lWorld . beePheremones) = w
|
||||
& cWorld . lWorld . creatures . ix cid . crType . beeAggro .~ 300
|
||||
| otherwise = w
|
||||
where
|
||||
f bp = distance (cr ^. crPos . _xy) (bp ^. bpPos . _xy) < 20
|
||||
@@ -196,14 +191,11 @@ updateCalmBee cr cid w
|
||||
| Just tid <- cr ^? crStance . carriage . mountID
|
||||
, Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w
|
||||
& tocr . crType . beeSlime +~ sspeed
|
||||
-- & cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract sspeed . (^(2::Int)))
|
||||
& cWorld . lWorld . creatures . ix tid . crType . slimeSlime -~ sspeed
|
||||
| Just (tcr,ti) <- gettarg
|
||||
, distance (cr ^. crPos . _xy) (tcr ^. crPos . _xy) < 0.8*crRad (tcr ^. crType)
|
||||
-- , Just r <- tcr ^? crType . slimeSlime . to slimeToRad
|
||||
, Just d <- tcr ^? crType . slimeCompression
|
||||
= w
|
||||
-- & tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos & _xy %~ compressionScale (vNormal ((1/r) *^d)))
|
||||
& tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos & _x %~ (/d) & _y *~ d)
|
||||
& tocr . crActionPlan . apAction .~ NoAction
|
||||
| Just (tcr,_) <- gettarg = w
|
||||
@@ -235,7 +227,6 @@ updateCalmBee cr cid w
|
||||
mcr <- w ^? cWorld . lWorld . creatures . ix mid
|
||||
SlimeCrit {_slimeSplitTimer = x} <- mcr ^? crType
|
||||
return $ isJust x
|
||||
--sspeed = 0.05
|
||||
sspeed = 5
|
||||
gettarg = do
|
||||
i <- cr ^? crActionPlan . apStrategy . harvestTarget
|
||||
@@ -273,7 +264,6 @@ slimeCritUpdate cid w
|
||||
| otherwise = Nothing
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
-- v = 0.1 *^ normalize p
|
||||
v = 0.1 *^ unitVectorAtAngle (cr ^. crDir)
|
||||
mvslime = cr & crType . slimeCompression +~ f (0.1/r)
|
||||
& crPos . _xy +~ v
|
||||
@@ -294,14 +284,12 @@ setSlimeDir cid cr w = do
|
||||
then do
|
||||
x <- randInCirc 1
|
||||
return $ fromMaybe w $ splitSlimeCrit' (x + cxy) (unitVectorAtAngle d) cid cr w
|
||||
-- else return $ w & tocr . crType . slimeCompression .~ r *^ unitVectorAtAngle d
|
||||
else return $ w & tocr . crDir .~ d
|
||||
& tocr . crType . slimeIsCompressing .~ False
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix cid
|
||||
cxy = cr ^. crPos . _xy
|
||||
r = cr ^?! crType . slimeSlime . to slimeToRad
|
||||
|
||||
|
||||
doSlimeRadChange :: Creature -> Creature
|
||||
doSlimeRadChange = crType . slimeSlimeChange %~ f
|
||||
@@ -343,8 +331,6 @@ splitSlimeCrit p v cr = do
|
||||
& crDir .~ argV (-mvdir)
|
||||
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)
|
||||
return (c1 & crType . slimeSplitTimer . _Just . _2 .~ f c1ps c1
|
||||
,c2 & crType . slimeSplitTimer . _Just . _2 .~ f c2ps c2
|
||||
)
|
||||
@@ -360,7 +346,6 @@ splitSlimeCrit p v cr = do
|
||||
& 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
|
||||
segmentArea r h = r*r*acos(1-h/r) - (r-h)*sqrt(h*(2*r-h))
|
||||
@@ -378,9 +363,6 @@ slinkCritUpdate cid w =
|
||||
. _2
|
||||
*~ Q.axisAngle (V3 0 1 0) (pi / 1000)
|
||||
|
||||
-- spineWalk :: [Point3Q]
|
||||
-- spineWalk = replicate 15 (V3
|
||||
|
||||
hoverCritHoverSound :: Creature -> World -> World
|
||||
hoverCritHoverSound cr w = fromMaybe w $ do
|
||||
guard $ d < 100
|
||||
@@ -417,9 +399,7 @@ checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix c
|
||||
checkDeath' :: Creature -> World -> World
|
||||
checkDeath' cr w = case cr ^. crHP of
|
||||
HP x | x > 0 -> w
|
||||
HP x
|
||||
| x > -200 && null (cr ^. crDeathTimer) ->
|
||||
w & tocr %~ startDeathTimer
|
||||
HP x | x > -200 && null (cr ^. crDeathTimer) -> w & tocr %~ startDeathTimer
|
||||
HP x
|
||||
| x > -200
|
||||
, Just y <- cr ^. crDeathTimer
|
||||
@@ -501,11 +481,6 @@ poisonSPic = _1 %~ overColSH (mixColors 0.5 0.5 green . normalizeColor)
|
||||
dropAll :: Creature -> World -> World
|
||||
dropAll cr w = foldl' (flip (dropItem cr)) w . reverse . IM.keys . _unNIntMap $ _crInv cr
|
||||
|
||||
-- startFalling :: Creature -> Creature
|
||||
-- startFalling cr = case cr ^. crStance . carriage of
|
||||
-- Walking -> cr & crStance . carriage .~ Falling
|
||||
-- _ -> cr & crStance . carriage .~ Falling
|
||||
|
||||
updatePulse :: Pulse -> Pulse
|
||||
updatePulse p
|
||||
| p ^. pulseProgress >= p ^. pulseRate = p & pulseProgress .~ 0
|
||||
|
||||
Reference in New Issue
Block a user