Fix worldEvent reset space leak
This commit is contained in:
@@ -29,7 +29,7 @@ impulsiveAIR
|
||||
-> Creature
|
||||
-> World
|
||||
-> (Endo World , Maybe Creature)
|
||||
impulsiveAIR impf cr w = followImpulses w . ($ w) . runReader $ impf cr
|
||||
impulsiveAIR impf cr w = bimap Endo Just $ followImpulses w . ($ w) . runReader $ impf cr
|
||||
|
||||
--impulsiveAI
|
||||
-- :: (World -> Creature -> Creature) -- ^ Internal AI update, should determine impulses
|
||||
@@ -43,10 +43,9 @@ impulsiveAIR impf cr w = followImpulses w . ($ w) . runReader $ impf cr
|
||||
followImpulses
|
||||
:: World
|
||||
-> Creature
|
||||
-> (Endo World, Maybe Creature)
|
||||
-> (World -> World, Creature)
|
||||
followImpulses w cr
|
||||
= (\(f''' ,cr') -> (Endo f''',Just cr'))
|
||||
$ foldr
|
||||
= foldr
|
||||
(\imp (f , cr') -> let (f'', cr'') = followImpulse cr' w imp in (f'' . f , cr''))
|
||||
(id, cr)
|
||||
(_crImpulse $ _crActionPlan cr)
|
||||
@@ -67,7 +66,7 @@ followImpulse cr w imp = case imp of
|
||||
SwitchToItem i -> (id, cr & crInvSel .~ i)
|
||||
Melee cid ->
|
||||
(hitCr cid
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown ?~ 20) -- randomise cooldown?
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown .~ 20) -- randomise cooldown?
|
||||
RandomTurn a -> (id, creatureTurn (rr a) cr)
|
||||
MakeSound sid -> ( soundOnceOrigin sid (CrSound (_crID cr)) (_crPos cr) , cr )
|
||||
DropItem -> undefined
|
||||
|
||||
Reference in New Issue
Block a user