small optimization and renames
This commit is contained in:
parent
e6f95e9c42
commit
51cb19aaac
3 changed files with 12 additions and 12 deletions
|
@ -348,7 +348,7 @@ drawMap = do
|
||||||
_ -> do
|
_ -> do
|
||||||
dt <- getDelta
|
dt <- getDelta
|
||||||
(_, (playerPos, posanims, posActions)) <- yieldSystemT (worldState ud) $ do
|
(_, (playerPos, posanims, posActions)) <- yieldSystemT (worldState ud) $ do
|
||||||
pc <- fmap head $ efor allEnts $ do
|
[pc] <- efor allEnts $ do
|
||||||
with player
|
with player
|
||||||
with pos
|
with pos
|
||||||
query pos
|
query pos
|
||||||
|
@ -407,7 +407,7 @@ drawMap = do
|
||||||
let delimiter (V2 nr nc, _, _) =
|
let delimiter (V2 nr nc, _, _) =
|
||||||
floor nr == r && floor nc == c
|
floor nr == r && floor nc == c
|
||||||
in L.partition delimiter list
|
in L.partition delimiter list
|
||||||
liftIO $ do -- draw floor
|
liftIO $ do
|
||||||
beginPath ctx
|
beginPath ctx
|
||||||
moveTo ctx (x + realToFrac tileWidth / 2) y
|
moveTo ctx (x + realToFrac tileWidth / 2) y
|
||||||
lineTo ctx
|
lineTo ctx
|
||||||
|
|
|
@ -234,7 +234,7 @@ updateStats dt =
|
||||||
where
|
where
|
||||||
doUpdate stat@(NPCStats conc blad thir hung food drin) as =
|
doUpdate stat@(NPCStats conc blad thir hung food drin) as =
|
||||||
stat
|
stat
|
||||||
{ statConcentration =
|
{ statAttention =
|
||||||
if as == ASWork
|
if as == ASWork
|
||||||
then max 0 (conc - 0.2 * dt)
|
then max 0 (conc - 0.2 * dt)
|
||||||
else min 1 (conc + 0.075 * dt)
|
else min 1 (conc + 0.075 * dt)
|
||||||
|
@ -248,11 +248,11 @@ updateStats dt =
|
||||||
, statDrink = max 0 (drin - 0.2 * dt)
|
, statDrink = max 0 (drin - 0.2 * dt)
|
||||||
}
|
}
|
||||||
doCompare ostat nstat as
|
doCompare ostat nstat as
|
||||||
| statConcentration nstat == 0 = ASRandWalk
|
| statAttention nstat == 0 = ASRandWalk
|
||||||
| statThirst nstat == 0 = ASDrink
|
| statThirst nstat == 0 = ASDrink
|
||||||
| statHunger nstat == 0 = ASDrink -- TODO: Let them eat
|
| statHunger nstat == 0 = ASDrink -- TODO: Let them eat
|
||||||
| statConcentration nstat > statConcentration ostat &&
|
| statAttention nstat > statAttention ostat &&
|
||||||
statConcentration nstat > 0.75 = ASWork
|
statAttention nstat > 0.75 = ASWork
|
||||||
| statBladder nstat > 0.9 = ASToilet
|
| statBladder nstat > 0.9 = ASToilet
|
||||||
| otherwise = as
|
| otherwise = as
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ data NPCActionState
|
||||||
deriving (Eq)
|
deriving (Eq)
|
||||||
|
|
||||||
data NPCStats = NPCStats
|
data NPCStats = NPCStats
|
||||||
{ statConcentration :: Double
|
{ statAttention :: Double
|
||||||
, statBladder :: Double
|
, statBladder :: Double
|
||||||
, statThirst :: Double
|
, statThirst :: Double
|
||||||
, statHunger :: Double
|
, statHunger :: Double
|
||||||
|
|
Loading…
Reference in a new issue