Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -29,7 +29,7 @@ fireShell it cr =
|
||||
|
||||
makeShell :: Item -> Creature -> [ProjectileUpdate] -> World -> World
|
||||
makeShell it cr theupdate w =
|
||||
w & cWorld . projectiles . at i
|
||||
w & cWorld . lWorld . projectiles . at i
|
||||
?~ Shell
|
||||
{ _prjPos = pos
|
||||
, _prjZ = 20
|
||||
@@ -46,7 +46,7 @@ makeShell it cr theupdate w =
|
||||
, _prjMITID = Just $ _itID it
|
||||
}
|
||||
where
|
||||
i = IM.newKey $ _props (_cWorld w)
|
||||
i = IM.newKey $ w ^. cWorld . lWorld . props-- _props (_cWorld w)
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
||||
am = _heldConsumption $ _itUse it
|
||||
|
||||
@@ -48,7 +48,7 @@ plainShellCollisionCheck :: Proj -> World -> World
|
||||
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
usePayload (_prjPayload pj) (_prjPos pj)
|
||||
. stopSoundFrom (ShellSound (_prjID pj))
|
||||
. (cWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
. (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
|
||||
upsProjectile :: Proj -> World -> World
|
||||
upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
||||
@@ -73,7 +73,7 @@ upProjectile pu pj = case pu of
|
||||
| otherwise -> id
|
||||
PJSetScope itid -> setRemoteScope itid (_prjPos pj)
|
||||
PJRetireRemote itid 0 pjid -> retireRemoteProj itid pjid
|
||||
PJRetireRemote _ _ pjid -> cWorld . projectiles . ix pjid . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
PJRetireRemote _ _ pjid -> cWorld . lWorld . projectiles . ix pjid . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
where
|
||||
time = _prjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
@@ -82,29 +82,29 @@ upProjectile pu pj = case pu of
|
||||
retireRemoteProj :: Int -> Int -> World -> World
|
||||
retireRemoteProj itid pjid w =
|
||||
w
|
||||
& pointerToItemLocation (_itemLocations (_cWorld w) IM.! itid)
|
||||
& pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itid)
|
||||
%~ ( (itScope . scopePos .~ V2 0 0)
|
||||
. (itUse . heldUse .~ HeldFireRemoteShell)
|
||||
)
|
||||
& cWorld . props %~ IM.delete pjid
|
||||
& cWorld . lWorld . props %~ IM.delete pjid
|
||||
|
||||
setRemoteDir :: Int -> Int -> Proj -> World -> World
|
||||
setRemoteDir cid itid pj w = w & cWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
setRemoteDir cid itid pj w = w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
where
|
||||
turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
--i = _prjID pj
|
||||
newdir
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w
|
||||
&& w ^? cWorld . creatures . ix cid . crInvSel . iselPos
|
||||
== w ^? cWorld . itemLocations . ix itid . ipInvID
|
||||
= (w ^. cWorld . cwCam . cwcRot) + argV (_mousePos w)
|
||||
&& w ^? cWorld . lWorld . creatures . ix cid . crInvSel . iselPos
|
||||
== w ^? cWorld . lWorld . itemLocations . ix itid . ipInvID
|
||||
= (w ^. cWorld . lWorld . cwCam . cwcRot) + argV (_mousePos w)
|
||||
| otherwise = _prjDir pj
|
||||
|
||||
doThrust :: Proj -> World -> World
|
||||
doThrust pj w =
|
||||
w
|
||||
& randGen .~ g
|
||||
& cWorld . projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& cWorld . lWorld . projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
|
||||
& makeFlamelet (oldPos -.- vel) 0 (vel +.+ rotateV (pi + sparkD) accel) 3 10
|
||||
& shellTrailCloud (addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)))
|
||||
@@ -126,11 +126,11 @@ trySpinByCID ::
|
||||
Proj ->
|
||||
World ->
|
||||
World
|
||||
trySpinByCID cid i pj w = w & cWorld . projectiles . ix pjid . prjSpin .~ newSpin
|
||||
trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin .~ newSpin
|
||||
where
|
||||
pjid = _prjID pj
|
||||
dir = argV $ _prjVel pj
|
||||
newSpin = case w ^? cWorld . creatures . ix cid of
|
||||
newSpin = case w ^? cWorld . lWorld . creatures . ix cid of
|
||||
Just cr -> negate $ min 0.2 $ max (-0.2) $ normalizeAnglePi (dir - _crDir cr) / spinFactor
|
||||
_ -> 0
|
||||
spinFactor = 5 * (6 - fromIntegral i)
|
||||
@@ -141,13 +141,13 @@ pjTrack itid pj w = rotateToTarget pj w
|
||||
rotateToTarget _ = fromMaybe id $ do
|
||||
tpos <- w ^? itPoint . itTargeting . tgPos . _Just
|
||||
return $
|
||||
cWorld . projectiles . ix (_prjID pj) . prjSpin
|
||||
cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin
|
||||
.~ turnToAmount
|
||||
0.15
|
||||
(_prjPos pj)
|
||||
tpos
|
||||
(argV $ _prjAcc pj)
|
||||
itPoint = pointerToItemLocation $ _itemLocations (_cWorld w) IM.! itid
|
||||
itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
|
||||
|
||||
reduceSpinBy :: Float -> Proj -> World -> World
|
||||
reduceSpinBy x pj = cWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
reduceSpinBy x pj = cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
|
||||
Reference in New Issue
Block a user