Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -4,7 +4,6 @@ import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Default
|
||||
import Dodge.SoundLogic
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
medkit :: Int -> Item
|
||||
medkit i =
|
||||
@@ -17,10 +16,10 @@ heal25 = heal 25
|
||||
|
||||
heal :: Int -> Int -> World -> Maybe World
|
||||
heal hp n w
|
||||
| _crHP (_creatures (_cWorld w) IM.! n) >= 10000 = Nothing
|
||||
| (w ^?! cWorld . lWorld . creatures . ix n . crHP) >= 10000 = Nothing
|
||||
| otherwise =
|
||||
Just $
|
||||
soundStart (CrSound $ _crID cr) (_crPos cr) healS Nothing w
|
||||
& cWorld . creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
& cWorld . lWorld . creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
where
|
||||
cr = _creatures (_cWorld w) IM.! n
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix n --_creatures (_cWorld w) IM.! n
|
||||
|
||||
@@ -9,11 +9,11 @@ import Dodge.Data.World
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
getItem itid w = do
|
||||
itpos <- w ^? cWorld . itemLocations . ix itid
|
||||
itpos <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
case itpos of
|
||||
OnFloor flitid -> w ^? cWorld . floorItems . ix flitid . flIt
|
||||
InInv cid invid -> w ^? cWorld . creatures . ix cid . crInv . ix invid
|
||||
OnTurret mcid -> w ^? cWorld . machines . ix mcid . mcType . _McTurret . tuWeapon
|
||||
OnFloor flitid -> w ^? cWorld . lWorld . floorItems . ix flitid . flIt
|
||||
InInv cid invid -> w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
OnTurret mcid -> w ^? cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuWeapon
|
||||
InVoid -> Nothing
|
||||
|
||||
pointerToItemLocation ::
|
||||
@@ -22,8 +22,8 @@ pointerToItemLocation ::
|
||||
(Item -> f Item) ->
|
||||
World ->
|
||||
f World
|
||||
pointerToItemLocation (InInv cid invid) = cWorld . creatures . ix cid . crInv . ix invid
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . floorItems . ix flid . flIt
|
||||
pointerToItemLocation (InInv cid invid) = cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . lWorld . floorItems . ix flid . flIt
|
||||
pointerToItemLocation _ = const pure
|
||||
|
||||
pointerToItem ::
|
||||
|
||||
@@ -9,24 +9,24 @@ initItemLocations :: CWorld -> CWorld
|
||||
initItemLocations = initCrsItemLocations . initFlItemsLocations . initTusItemLocations
|
||||
|
||||
initCrsItemLocations :: CWorld -> CWorld
|
||||
initCrsItemLocations w = w' & creatures .~ newcreatures
|
||||
initCrsItemLocations w = w' & lWorld . creatures .~ newcreatures
|
||||
where
|
||||
(w', newcreatures) = mapAccumR initCrItemLocations w (_creatures w)
|
||||
(w', newcreatures) = mapAccumR initCrItemLocations w (w ^. lWorld . creatures)
|
||||
|
||||
initFlItemsLocations :: CWorld -> CWorld
|
||||
initFlItemsLocations w = w' & floorItems .~ newfloorItems
|
||||
initFlItemsLocations w = w' & lWorld . floorItems .~ newfloorItems
|
||||
where
|
||||
(w', newfloorItems) = mapAccumR initFlItemLocation w (_floorItems w)
|
||||
(w', newfloorItems) = mapAccumR initFlItemLocation w (w ^. lWorld . floorItems)
|
||||
|
||||
initTusItemLocations :: CWorld -> CWorld
|
||||
initTusItemLocations w = w' & machines .~ newmachines
|
||||
initTusItemLocations w = w' & lWorld . machines .~ newmachines
|
||||
where
|
||||
(w', newmachines) = mapAccumR initTuItemLocation w (_machines w)
|
||||
(w', newmachines) = mapAccumR initTuItemLocation w (w ^. lWorld . machines)
|
||||
|
||||
initSpecificCrItemLocations :: Int -> CWorld -> CWorld
|
||||
initSpecificCrItemLocations crid w = w' & creatures . ix crid .~ newcr
|
||||
initSpecificCrItemLocations crid w = w' & lWorld . creatures . ix crid .~ newcr
|
||||
where
|
||||
(w',newcr) = initCrItemLocations w (w ^?! creatures . ix crid)
|
||||
(w',newcr) = initCrItemLocations w (w ^?! lWorld . creatures . ix crid)
|
||||
|
||||
initCrItemLocations :: CWorld -> Creature -> (CWorld, Creature)
|
||||
initCrItemLocations w cr = (w', cr & crInv .~ newinv)
|
||||
@@ -34,30 +34,30 @@ initCrItemLocations w cr = (w', cr & crInv .~ newinv)
|
||||
(w',newinv) = imapAccumR (initCrItemLocation cr) w (_crInv cr)
|
||||
|
||||
initCrItemLocation :: Creature -> Int -> CWorld -> Item -> (CWorld,Item)
|
||||
initCrItemLocation cr invid w it = (w & itemLocations . at locid ?~ loc
|
||||
initCrItemLocation cr invid w it = (w & lWorld . itemLocations . at locid ?~ loc
|
||||
,it & itID .~ locid
|
||||
& itLocation .~ loc)
|
||||
where
|
||||
locid = IM.newKey (_itemLocations w)
|
||||
locid = IM.newKey ( w ^. lWorld . itemLocations)
|
||||
loc = InInv (_crID cr) invid
|
||||
|
||||
|
||||
initFlItemLocation :: CWorld -> FloorItem -> (CWorld, FloorItem)
|
||||
initFlItemLocation w flit = (w & itemLocations . at locid ?~ loc
|
||||
initFlItemLocation w flit = (w & lWorld . itemLocations . at locid ?~ loc
|
||||
, flit & flIt . itID .~ locid
|
||||
& flIt . itLocation .~ loc
|
||||
)
|
||||
where
|
||||
locid = IM.newKey (_itemLocations w)
|
||||
locid = IM.newKey (w ^. lWorld . itemLocations )
|
||||
loc = OnFloor (_flItID flit)
|
||||
|
||||
initTuItemLocation :: CWorld -> Machine -> (CWorld, Machine)
|
||||
initTuItemLocation w mc = case mc ^? mcType . _McTurret . tuWeapon of
|
||||
Nothing -> (w, mc)
|
||||
Just _ ->
|
||||
let locid = IM.newKey (_itemLocations w)
|
||||
let locid = IM.newKey ( w ^. lWorld . itemLocations)
|
||||
loc = OnTurret (_mcID mc)
|
||||
in ( w & itemLocations . at locid ?~ loc
|
||||
in ( w & lWorld . itemLocations . at locid ?~ loc
|
||||
, mc & mcType . _McTurret . tuWeapon . itID .~ locid
|
||||
& mcType . _McTurret . tuWeapon . itLocation .~ loc
|
||||
)
|
||||
|
||||
@@ -132,7 +132,7 @@ import Picture
|
||||
|
||||
|
||||
shootLaser :: Item -> Creature -> World -> World
|
||||
shootLaser it cr = cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
shootLaser it cr = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
where
|
||||
pos = _crPos cr
|
||||
dir = _crDir cr
|
||||
@@ -144,7 +144,7 @@ circleLaser :: Item -> Creature -> World -> World
|
||||
circleLaser it cr w
|
||||
| hasLOSIndirect cpos pos w =
|
||||
w
|
||||
& cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
& cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
| otherwise = w
|
||||
where
|
||||
cpos = _crPos cr
|
||||
@@ -157,8 +157,8 @@ circleLaser it cr w
|
||||
shootDualLaser :: Item -> Creature -> World -> World
|
||||
shootDualLaser it cr w =
|
||||
w
|
||||
& cWorld . newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
|
||||
& cWorld . newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
|
||||
& cWorld . lWorld . newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
|
||||
& cWorld . lWorld . newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
|
||||
where
|
||||
itid = _itID it
|
||||
dir = _crDir cr
|
||||
@@ -200,7 +200,7 @@ dualRayAt bt itid w col dam phasev pos dir =
|
||||
& bmType .~ bt
|
||||
|
||||
aTractorBeam :: Item -> Creature -> World -> World
|
||||
aTractorBeam _ cr w = w & cWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||
aTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||
where
|
||||
cpos = _crPos cr
|
||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||
|
||||
@@ -38,7 +38,7 @@ autoEffect :: (Item -> Creature -> World -> World) -> Int -> SoundID -> Item ->
|
||||
autoEffect eff t sid itm cr w
|
||||
| _eparamInt (_eeParams (_equipEffect $ _itUse itm)) < 1 =
|
||||
eff itm cr w
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
|
||||
. itUse
|
||||
. equipEffect
|
||||
. eeParams
|
||||
@@ -47,7 +47,7 @@ autoEffect eff t sid itm cr w
|
||||
& soundStart OnceSound (_crPos cr) sid Nothing
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
|
||||
. itUse
|
||||
. equipEffect
|
||||
. eeParams
|
||||
@@ -86,10 +86,10 @@ targetRBCreatureUp it cr w t
|
||||
mwp = mouseWorldPos w
|
||||
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
|
||||
posFromMaybeID Nothing = Nothing
|
||||
posFromMaybeID (Just i) = w ^? cWorld . creatures . ix i . crPos
|
||||
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
||||
canSeeTarget = fromMaybe False $ do
|
||||
cid <- t ^? tgID . _Just
|
||||
cpos <- w ^? cWorld . creatures . ix cid . crPos
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
|
||||
targetUpdateWith ::
|
||||
@@ -141,7 +141,7 @@ targetLaserUpdate _ cr w t
|
||||
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos w -.- sp)
|
||||
addLaserPic =
|
||||
cWorld . lasers
|
||||
cWorld . lWorld . lasers
|
||||
.:~ LaserStart
|
||||
{ _lpPhaseV = 1
|
||||
, _lpDir = _crDir cr
|
||||
|
||||
@@ -6,7 +6,6 @@ import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Item.Location
|
||||
import Dodge.Payload
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
explodeRemoteRocket ::
|
||||
-- | Item id
|
||||
@@ -17,10 +16,10 @@ explodeRemoteRocket ::
|
||||
World
|
||||
explodeRemoteRocket itid pjid w =
|
||||
w
|
||||
& cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||
& cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& itPoint . itUse . heldUse .~ HeldDoNothing
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
where
|
||||
itPoint = pointerToItemLocation $ _itemLocations (_cWorld w) IM.! itid
|
||||
thepj = _projectiles (_cWorld w) IM.! pjid
|
||||
itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
|
||||
thepj = w ^?! cWorld . lWorld . projectiles . ix pjid
|
||||
|
||||
@@ -7,24 +7,23 @@ import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Default
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
setRemoteBombScope :: Int -> Prop -> World -> World
|
||||
setRemoteBombScope itid pj w' = case _itemLocations (_cWorld w') IM.! itid of
|
||||
setRemoteBombScope itid pj w = case w ^?! cWorld . lWorld . itemLocations . ix itid of
|
||||
InInv cid invid ->
|
||||
w'
|
||||
& cWorld . creatures . ix cid . crInv . ix invid . itScope
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos
|
||||
.~ (_prPos pj -.- _crPos (_creatures (_cWorld w') IM.! cid))
|
||||
& cWorld . creatures . ix cid . crInv . ix invid . itUse . heldAim . aimZoom
|
||||
.~ (_prPos pj -.- (w ^?! cWorld . lWorld . creatures . ix cid . crPos))
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse . heldAim . aimZoom
|
||||
.~ (defaultItZoom{_itZoomMax = 0.5, _itZoomMin = 0.5})
|
||||
_ -> w'
|
||||
_ -> w
|
||||
|
||||
setRemoteScope :: Int -> Point2 -> World -> World
|
||||
setRemoteScope itid pos w' = case w' ^? cWorld . itemLocations . ix itid of
|
||||
setRemoteScope itid pos w = case w ^? cWorld . lWorld . itemLocations . ix itid of
|
||||
Just (InInv cid' invid) ->
|
||||
w'
|
||||
& cWorld . creatures . ix cid' . crInv . ix invid . itScope
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix cid' . crInv . ix invid . itScope
|
||||
. scopePos
|
||||
.~ (pos -.- _crPos (_creatures (_cWorld w') IM.! cid'))
|
||||
_ -> w'
|
||||
.~ (pos -.- (w ^?! cWorld . lWorld . creatures . ix cid' . crPos))
|
||||
_ -> w
|
||||
|
||||
@@ -8,7 +8,7 @@ import Geometry.Vector
|
||||
|
||||
decTimMvVel :: Proj -> World -> World
|
||||
decTimMvVel pj =
|
||||
cWorld . projectiles . ix pjid
|
||||
cWorld . lWorld . projectiles . ix pjid
|
||||
%~ ( (prjTimer -~ 1)
|
||||
. (prjPos %~ (+.+ vel))
|
||||
. (prjAcc %~ rotateV rot)
|
||||
|
||||
@@ -24,9 +24,9 @@ spawnCrNextTo ::
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
spawnCrNextTo cr sCr w = w & cWorld . creatures %~ IM.insert k newCr
|
||||
spawnCrNextTo cr sCr w = w & cWorld . lWorld . creatures %~ IM.insert k newCr
|
||||
where
|
||||
k = IM.newKey $ _creatures (_cWorld w)
|
||||
k = IM.newKey $ w ^?! cWorld . lWorld . creatures -- _creatures (_cWorld w)
|
||||
newCr =
|
||||
cr
|
||||
& crID .~ k
|
||||
|
||||
@@ -90,7 +90,7 @@ type ChainEffect =
|
||||
|
||||
lockInvFor :: Int -> ChainEffect
|
||||
lockInvFor i f it cr =
|
||||
f it cr . (cWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
|
||||
f it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
|
||||
. lockInv (_crID cr)
|
||||
|
||||
trigDoAlso' ::
|
||||
@@ -138,7 +138,7 @@ withThickSmokeI eff item cr w =
|
||||
ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff itm cr w
|
||||
| _laLoaded ic <= 0 || not (_laPrimed ic) = w
|
||||
| otherwise = eff itm cr $ w & cWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
| otherwise = eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
where
|
||||
ic = _heldConsumption $ _itUse itm
|
||||
|
||||
@@ -148,7 +148,7 @@ ammoHammerCheck :: ChainEffect
|
||||
ammoHammerCheck eff it cr w
|
||||
| _laLoaded ic <= 0 || not (_laPrimed ic) = w -- fromMaybe w (startReloadingWeapon cr w)
|
||||
| otherwise = case it ^? itUse . heldHammer of
|
||||
Just HammerUp -> eff it cr $ w & cWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
Just HammerUp -> eff it cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
_ -> w
|
||||
where
|
||||
ic = _heldConsumption $ _itUse it
|
||||
@@ -192,7 +192,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
||||
startRate = _rateMaxMax . _heldDelay $ _itUse item
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||
currentRate = _rateMax (_heldDelay (_itUse item))
|
||||
repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item)) == 1
|
||||
firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item)) == 0
|
||||
@@ -216,7 +216,7 @@ withWarmUp soundID f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||
curWarmUp = _warmTime . _heldDelay $ _itUse item
|
||||
maxWarmUp = _warmMax . _heldDelay $ _itUse item
|
||||
|
||||
@@ -291,13 +291,13 @@ afterRecoil ::
|
||||
-- | Recoil amount
|
||||
Float ->
|
||||
ChainEffect
|
||||
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (cWorld . creatures . ix cid) pushback
|
||||
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (cWorld . lWorld . creatures . ix cid) pushback
|
||||
where
|
||||
cid = _crID cr
|
||||
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount) / _crMass cr) 0))
|
||||
|
||||
withRecoil :: ChainEffect
|
||||
withRecoil eff it cr = eff it cr . over (cWorld . creatures . ix cid) pushback
|
||||
withRecoil eff it cr = eff it cr . over (cWorld . lWorld . creatures . ix cid) pushback
|
||||
where
|
||||
cid = _crID cr
|
||||
recoilAmount = fromMaybe 0 $ it ^? itParams . recoil
|
||||
@@ -313,7 +313,7 @@ withSidePushI ::
|
||||
withSidePushI maxSide eff item cr w =
|
||||
eff item (push cr) $
|
||||
w
|
||||
& cWorld . creatures . ix cid %~ push
|
||||
& cWorld . lWorld . creatures . ix cid %~ push
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -330,7 +330,7 @@ withSidePushAfterI ::
|
||||
Float ->
|
||||
ChainEffect
|
||||
withSidePushAfterI maxSide eff item cr w =
|
||||
over (cWorld . creatures . ix cid) push . eff item cr $
|
||||
over (cWorld . lWorld . creatures . ix cid) push . eff item cr $
|
||||
w
|
||||
& randGen .~ g
|
||||
where
|
||||
@@ -341,19 +341,19 @@ withSidePushAfterI maxSide eff item cr w =
|
||||
useAllAmmo :: ChainEffect
|
||||
useAllAmmo eff item cr =
|
||||
eff item cr
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded .~ 0)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded .~ 0)
|
||||
|
||||
useAmmoUpTo :: Int -> ChainEffect
|
||||
useAmmoUpTo amAmount eff item cr =
|
||||
eff item cr
|
||||
. ( cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded
|
||||
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded
|
||||
%~ (max 0 . subtract amAmount)
|
||||
)
|
||||
|
||||
useAmmoAmount :: Int -> ChainEffect
|
||||
useAmmoAmount amAmount eff item cr =
|
||||
eff item cr
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded -~ amAmount)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded -~ amAmount)
|
||||
|
||||
{- |
|
||||
Applies a world effect after an item use cooldown check.
|
||||
@@ -364,7 +364,7 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
|
||||
_ -> w
|
||||
where
|
||||
cid = _crID cr
|
||||
setUseTime = cWorld . creatures . ix cid . crInv . ix (crSel cr) . itUse . heldDelay . rateTime +~ userate
|
||||
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix (crSel cr) . itUse . heldDelay . rateTime +~ userate
|
||||
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
|
||||
|
||||
-- | Applies a world effect after a hammer position check.
|
||||
@@ -390,7 +390,7 @@ ammoUseCheck f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||
fireCondition =
|
||||
crWeaponReady cr
|
||||
&& _rateTime (_heldDelay (_itUse item)) == 0
|
||||
@@ -433,7 +433,7 @@ shootL f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
invid = _ipInvID $ _itLocation item
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix invid
|
||||
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
fireCondition =
|
||||
_rateTime (_leftDelay (_itUse item)) == 0
|
||||
&& _arLoaded (_leftConsumption (_itUse item)) > 0
|
||||
@@ -444,15 +444,15 @@ withItem g f it = g it f it
|
||||
|
||||
-- not ideal
|
||||
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
||||
withItemUpdate' up f it cr = f (up it) cr . (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
|
||||
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
|
||||
withItemUpdate up g f it cr = g it f it cr . (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
|
||||
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
||||
withTempLight time rad col eff item cr =
|
||||
eff item cr
|
||||
. over (cWorld . tempLightSources) (theTLS :)
|
||||
. over (cWorld . lWorld . tempLightSources) (theTLS :)
|
||||
where
|
||||
theTLS = tlsTimeRadColPos time rad col (V3 x y 10)
|
||||
V2 x y = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||
@@ -578,9 +578,9 @@ torqueBefore torque feff item cr w
|
||||
feff item (cr & crDir +~ rot) $
|
||||
w
|
||||
& randGen .~ g
|
||||
& cWorld . creatures . ix cid . crDir +~ rot
|
||||
& cWorld . cwCam . cwcRot +~ rot
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . creatures . ix cid . crDir) (+ rot) w
|
||||
& cWorld . lWorld . creatures . ix cid . crDir +~ rot
|
||||
& cWorld . lWorld . cwCam . cwcRot +~ rot
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (- torque, torque) $ _randGen w
|
||||
@@ -599,9 +599,9 @@ torqueBeforeAtLeast minTorque exTorque feff item cr w
|
||||
feff item (cr & crDir +~ rot') $
|
||||
w
|
||||
& randGen .~ g
|
||||
& cWorld . creatures . ix cid . crDir +~ rot'
|
||||
& cWorld . cwCam . cwcRot +~ rot'
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . creatures . ix cid . crDir) (+ rot') w
|
||||
& cWorld . lWorld . creatures . ix cid . crDir +~ rot'
|
||||
& cWorld . lWorld . cwCam . cwcRot +~ rot'
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot') w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (- exTorque, exTorque) $ _randGen w
|
||||
@@ -613,8 +613,8 @@ torqueBeforeAtLeast minTorque exTorque feff item cr w
|
||||
withTorqueAfter :: ChainEffect
|
||||
withTorqueAfter feff item cr w
|
||||
-- | cid == 0 = rotateScope $ set randGen g $ over cameraRot (+rot) $ feff item cr w
|
||||
| cid == 0 = set randGen g $ over (cWorld . cwCam . cwcRot) (+ rot) $ feff item cr w
|
||||
| otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+ rot) $ feff item cr w
|
||||
| cid == 0 = set randGen g $ over (cWorld . lWorld . cwCam . cwcRot) (+ rot) $ feff item cr w
|
||||
| otherwise = set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) $ feff item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (- torque, torque) $ _randGen w
|
||||
@@ -647,12 +647,12 @@ sideEffectOnFrame ::
|
||||
ChainEffect
|
||||
sideEffectOnFrame i sf f it cr w =
|
||||
f it cr w
|
||||
& cWorld . delayedEvents .:~ (i, sf it cr)
|
||||
& cWorld . lWorld . delayedEvents .:~ (i, sf it cr)
|
||||
|
||||
torqueSideEffect :: Float -> Item -> Creature -> World -> World
|
||||
torqueSideEffect torque _ cr w
|
||||
| cid == 0 = set randGen g $ over (cWorld . cwCam . cwcRot) (+ rot) w
|
||||
| otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+ rot) w
|
||||
| cid == 0 = set randGen g $ over (cWorld . lWorld . cwCam . cwcRot) (+ rot) w
|
||||
| otherwise = set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (- torque, torque) $ _randGen w
|
||||
@@ -663,7 +663,7 @@ repeatOnFrames :: [Int] -> HeldMod -> ChainEffect
|
||||
repeatOnFrames is hm f it cr w =
|
||||
f it cr $
|
||||
w
|
||||
& cWorld . delayedEvents .++~ (is <&> (,WdWdFromItCrixWdWd (it & itUse . heldMods .~ hm) (_crID cr) ItCrWdItemEffect))
|
||||
& cWorld . lWorld . delayedEvents .++~ (is <&> (,WdWdFromItCrixWdWd (it & itUse . heldMods .~ hm) (_crID cr) ItCrWdItemEffect))
|
||||
|
||||
-- where
|
||||
-- f' = fromMaybe w' $ do
|
||||
|
||||
@@ -89,11 +89,11 @@ useForceFieldGun itm cr w = fromMaybe w $ do
|
||||
wlline = (a, b)
|
||||
return $
|
||||
w
|
||||
& cWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
|
||||
& cWorld . lWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
|
||||
& moveWallIDUnsafe i wlline
|
||||
where
|
||||
i = fromMaybe (IM.newKey (_walls (_cWorld w))) $ itm ^? itParams . paramMID . _Just
|
||||
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just
|
||||
|
||||
-- grapGun = defaultGun
|
||||
-- { _itName = "grapGun"
|
||||
|
||||
Reference in New Issue
Block a user