Creature zoning refactor
This commit is contained in:
+6
-4
@@ -149,7 +149,8 @@ doRewind w = case _maybeWorld w of
|
||||
zoneCreatures :: World -> World
|
||||
zoneCreatures w = w
|
||||
& creaturesZone . znObjects .~
|
||||
runIdentity (S.fold_ zoneCreature IM.empty id (S.each $ _creatures w))
|
||||
IM.foldl' zoneCreature IM.empty (_creatures w)
|
||||
-- runIdentity (S.fold_ zoneCreature IM.empty id (S.each $ _creatures w))
|
||||
|
||||
zoneCreature :: IM.IntMap (IM.IntMap (IM.IntMap Creature))
|
||||
-> Creature
|
||||
@@ -347,7 +348,7 @@ updateCloud w c
|
||||
newVel@(V3 _ _ nvz) = (0.95 *.*.* springVels) +.+.+ V3 0 0 (0.001 * vertVel)
|
||||
newVel2 = stripZ newVel
|
||||
vertVel = _clAlt c - opz
|
||||
springVels = runIdentity $ S.fold_ (clClSpringVel c) (_clVel c) id (cloudsNearPoint oldPos2 w)
|
||||
springVels = runIdentity $ S.fold_ (clClSpringVel c) (_clVel c) id (clsNearPoint oldPos2 w)
|
||||
oldPos@(V3 _ _ opz) = _clPos c
|
||||
oldPos2 = stripZ oldPos
|
||||
newPos@(V3 _ _ npz) = oldPos +.+.+ newVel
|
||||
@@ -369,10 +370,11 @@ clClSpringVel a v b
|
||||
simpleCrSprings :: World -> World
|
||||
simpleCrSprings w = IM.foldl' (flip crSpring) w $ _creatures w
|
||||
|
||||
-- note that this may in rare cases not push creatures away from each other
|
||||
crSpring :: Creature -> World -> World
|
||||
crSpring c w = IM.foldl' (flip $ crCrSpring c) w cs
|
||||
crSpring c w = runIdentity $ S.fold_ (flip $ crCrSpring c) w id cs
|
||||
where
|
||||
cs = creaturesNearPoint (_crPos c) w
|
||||
cs = crsNearPoint (_crPos c) w
|
||||
|
||||
crCrSpring :: Creature -> Creature -> World -> World
|
||||
crCrSpring c1 c2
|
||||
|
||||
Reference in New Issue
Block a user