Fix worldEvent reset space leak

This commit is contained in:
2021-08-18 13:18:46 +02:00
parent a6f08aef16
commit 910c29a510
12 changed files with 34 additions and 33 deletions
+4 -5
View File
@@ -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