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