Separate out concrete part of world
This commit is contained in:
@@ -15,8 +15,8 @@ import qualified IntMapHelp as IM
|
||||
charFiringStratI
|
||||
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
|
||||
-> ChainEffect
|
||||
charFiringStratI strats eff item cr w = case w ^? creatures . ix cid . crInv
|
||||
. ix (crSel $ _creatures w IM.! cid) . itAttachment . atCharMode of
|
||||
charFiringStratI strats eff item cr w = case w ^? cWorld . creatures . ix cid . crInv
|
||||
. ix (crSel $ _creatures (_cWorld w) IM.! cid) . itAttachment . atCharMode of
|
||||
Just (c :<| _) -> fromMaybe id (Prelude.lookup c strats) eff item cr w
|
||||
_ -> w
|
||||
where
|
||||
|
||||
@@ -24,8 +24,8 @@ medkit i = defaultConsumable
|
||||
heal25 :: Int -> World -> Maybe World
|
||||
heal25 = heal 25
|
||||
heal :: Int -> Int -> World -> Maybe World
|
||||
heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing
|
||||
heal hp n w | _crHP (_creatures (_cWorld w) IM.! n) >= 10000 = Nothing
|
||||
| otherwise = Just $ soundStart (CrSound $ _crID cr) (_crPos cr) healS Nothing w
|
||||
& creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
& cWorld . creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
where
|
||||
cr = _creatures w IM.! n
|
||||
cr = _creatures (_cWorld w) IM.! n
|
||||
|
||||
+10
-10
@@ -51,7 +51,7 @@ magShield = defaultEquipment
|
||||
& itUse . eqEq . eqSite .~ GoesOnWrist
|
||||
& itType . iyBase .~ EQUIP MAGSHIELD
|
||||
useMagShield :: Item -> Creature -> World -> World
|
||||
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
|
||||
useMagShield it cr w = w & cWorld . magnets . at mgid ?~ themagnet
|
||||
where
|
||||
themagnet = Magnet
|
||||
{_mgID = mgid
|
||||
@@ -61,7 +61,7 @@ useMagShield it cr w = w & magnets . at mgid ?~ themagnet
|
||||
}
|
||||
mgid = case it ^? itAttachment . atMInt . _Just of
|
||||
Just mgid' -> mgid'
|
||||
Nothing -> IM.newKey $ _magnets w
|
||||
Nothing -> IM.newKey $ _magnets (_cWorld w)
|
||||
-- it = _crInv cr IM.! invid
|
||||
|
||||
flameShield :: Item
|
||||
@@ -89,15 +89,15 @@ wristArmour = defaultEquipment
|
||||
|
||||
onEquipWristShield :: Item -> Creature -> World -> World
|
||||
onEquipWristShield itm cr w = w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itUse . eqEq . eqParams .~ EquipID i
|
||||
& walls . at i ?~ forceField {_wlID = i}
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itUse . eqEq . eqParams .~ EquipID i
|
||||
& cWorld . walls . at i ?~ forceField {_wlID = i}
|
||||
& setWristShieldPos (itm & itUse . eqEq . eqParams .~ EquipID i) cr
|
||||
where
|
||||
i = IM.newKey (_walls w)
|
||||
i = IM.newKey (_walls (_cWorld w))
|
||||
|
||||
onRemoveWristShield :: Item -> Creature -> World -> World
|
||||
onRemoveWristShield itm cr w = w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itUse . eqEq . eqParams .~ NoEquipParams
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itUse . eqEq . eqParams .~ NoEquipParams
|
||||
& deleteWallID i
|
||||
where
|
||||
i = _eparamID $ _eqParams $ _eqEq $ _itUse itm
|
||||
@@ -168,7 +168,7 @@ shieldWall crid = defaultWall
|
||||
createShieldWall :: Item -> Creature -> World -> World
|
||||
createShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||
Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w
|
||||
in w' & creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
|
||||
in w' & cWorld . creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
|
||||
Just wid -> moveWallID wid wlline w
|
||||
where
|
||||
invid = fromJust $ _itID it
|
||||
@@ -185,7 +185,7 @@ removeShieldWall :: Item -> Creature -> World -> World
|
||||
removeShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||
Nothing -> w
|
||||
Just wid -> w & deleteWallID wid
|
||||
& creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
|
||||
& cWorld . creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
|
||||
where
|
||||
crid = _crID cr
|
||||
invid = fromJust (_itID it)
|
||||
@@ -241,7 +241,7 @@ headLamp = defaultEquipment
|
||||
|
||||
|
||||
createHeadLamp :: Item -> Creature -> World -> World
|
||||
createHeadLamp _ cr = tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
|
||||
createHeadLamp _ cr = cWorld . tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
|
||||
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr) (translatePointToHead cr (V3 5 0 3)))
|
||||
|
||||
powerLegs :: Item
|
||||
@@ -268,4 +268,4 @@ wristInvisibility = defaultEquipment
|
||||
& itType . iyBase .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
|
||||
|
||||
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
|
||||
overCID f _ cr = creatures . ix (_crID cr) %~ f
|
||||
overCID f _ cr = cWorld . creatures . ix (_crID cr) %~ f
|
||||
|
||||
@@ -40,10 +40,10 @@ boostSelfL x itm cr w = case boostPoint x cr w of
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
r = _crRad cr
|
||||
pid = fromMaybe (IM.newKey $ _props w)
|
||||
pid = fromMaybe (IM.newKey $ _props (_cWorld w))
|
||||
(cr ^? crInv . ix invid . itAttachment . atInt)
|
||||
crEff p ammoEff = addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
|
||||
& creatures . ix cid %~
|
||||
& cWorld . creatures . ix cid %~
|
||||
(crPos .~ p)
|
||||
. (crInv . ix invid %~
|
||||
ammoEff
|
||||
@@ -57,7 +57,7 @@ addBoostShockwave
|
||||
-> Point2
|
||||
-> World
|
||||
-> World
|
||||
addBoostShockwave pjid p v w = w & linearShockwaves %~
|
||||
addBoostShockwave pjid p v w = w & cWorld . linearShockwaves %~
|
||||
IM.insertWith f pjid thePJ
|
||||
where
|
||||
thePJ = LinearShockwave
|
||||
|
||||
@@ -11,27 +11,27 @@ setHeldItemLoc cr = fst . getHeldItemLoc cr
|
||||
getHeldItemLoc :: Creature -> World -> (World,Int)
|
||||
getHeldItemLoc cr w = case maybeitid of
|
||||
Nothing ->
|
||||
( w & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
||||
( w & cWorld . creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
& cWorld . itemPositions %~ IM.insert newitid (InInv cid j)
|
||||
, itid)
|
||||
_ -> (w, itid)
|
||||
where
|
||||
cid = _crID cr
|
||||
j = crSel cr
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
newitid = IM.newKey $ _itemPositions (_cWorld w)
|
||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||
itid = fromMaybe newitid maybeitid
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
getItem itid w = do
|
||||
itpos <- w ^? itemPositions . ix itid
|
||||
itpos <- w ^? cWorld . itemPositions . ix itid
|
||||
case itpos of
|
||||
OnFloor flitid -> w ^? floorItems . ix flitid . flIt
|
||||
InInv cid invid -> w ^? creatures . ix cid . crInv . ix invid
|
||||
OnFloor flitid -> w ^? cWorld . floorItems . ix flitid . flIt
|
||||
InInv cid invid -> w ^? cWorld . creatures . ix cid . crInv . ix invid
|
||||
VoidItm -> Nothing
|
||||
|
||||
pointToItem :: Applicative f =>
|
||||
ItemPos -> (Item -> f Item) -> World -> f World
|
||||
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
|
||||
pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||
pointToItem (InInv cid invid) = cWorld . creatures . ix cid . crInv . ix invid
|
||||
pointToItem (OnFloor flid) = cWorld . floorItems . ix flid . flIt
|
||||
pointToItem _ = const pure
|
||||
|
||||
@@ -276,14 +276,14 @@ tractorGunTweak = TweakParam
|
||||
-- | assumes that the item is held
|
||||
shootTeslaArc :: Item -> Creature -> World -> World
|
||||
shootTeslaArc it cr w = w'
|
||||
& creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
|
||||
where
|
||||
(w',ip) = shootTeslaArc' (_itParams it) pos dir w
|
||||
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
|
||||
shootLaser :: Item -> Creature -> World -> World
|
||||
shootLaser it cr = lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
shootLaser it cr = cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
where
|
||||
pos = _crPos cr
|
||||
dir = _crDir cr
|
||||
@@ -294,7 +294,7 @@ shootLaser it cr = lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos
|
||||
circleLaser :: Item -> Creature -> World -> World
|
||||
circleLaser it cr w
|
||||
| hasLOSIndirect cpos pos w = w
|
||||
& lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
& cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
| otherwise = w
|
||||
where
|
||||
cpos = _crPos cr
|
||||
@@ -306,8 +306,8 @@ circleLaser it cr w
|
||||
|
||||
shootDualLaser :: Item -> Creature -> World -> World
|
||||
shootDualLaser it cr w = w'
|
||||
& newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
|
||||
& newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
|
||||
& 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
|
||||
where
|
||||
(w',itid) = getHeldItemLoc cr w
|
||||
dir = _crDir cr
|
||||
@@ -346,7 +346,7 @@ dualRayAt bt itid w col dam phasev pos dir = basicBeamAt itid w col dam phasev p
|
||||
& bmType .~ bt
|
||||
|
||||
aTractorBeam :: Item -> Creature -> World -> World
|
||||
aTractorBeam _ cr w = w & tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||
aTractorBeam _ cr w = w & cWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||
where
|
||||
cpos = _crPos cr
|
||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||
|
||||
@@ -38,11 +38,11 @@ import qualified SDL
|
||||
autoEffect :: (Item -> Creature -> World -> World) -> Int -> SoundID -> Item -> Creature -> World -> World
|
||||
autoEffect eff t sid itm cr w
|
||||
| _eparamInt (_eqParams (_eqEq $ _itUse itm)) < 1 = eff itm cr w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
. itUse . eqEq . eqParams . eparamInt .~ t
|
||||
& soundStart OnceSound (_crPos cr) sid Nothing
|
||||
| otherwise = w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
. itUse . eqEq . eqParams . eparamInt -~ 1
|
||||
|
||||
{- | Automatically send out radar pulses that detect walls. -}
|
||||
@@ -83,7 +83,7 @@ targetRBCreatureUp it cr w t
|
||||
& tgPos .~ Nothing
|
||||
& tgActive .~ False
|
||||
)
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w && isJust (t ^? tgID . _Just)
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) && isJust (t ^? tgID . _Just)
|
||||
&& canSeeTarget = (w, t & updatePos
|
||||
& tgActive .~ True
|
||||
)
|
||||
@@ -99,10 +99,10 @@ targetRBCreatureUp it cr w t
|
||||
mwp = mouseWorldPos w
|
||||
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
|
||||
posFromMaybeID Nothing = Nothing
|
||||
posFromMaybeID (Just i) = w ^? creatures . ix i . crPos
|
||||
posFromMaybeID (Just i) = w ^? cWorld . creatures . ix i . crPos
|
||||
canSeeTarget = fromMaybe False $ do
|
||||
cid <- t ^? tgID . _Just
|
||||
cpos <- w ^? creatures . ix cid . crPos
|
||||
cpos <- w ^? cWorld . creatures . ix cid . crPos
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
|
||||
targetUpdateWith :: (World -> Targeting -> Targeting)
|
||||
@@ -113,7 +113,7 @@ targetUpdateWith f it _ w t
|
||||
|
||||
targetCursorUpdate :: World -> Targeting -> Targeting
|
||||
targetCursorUpdate w t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w = t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) = t
|
||||
& tgPos . _Just .~ mouseWorldPos w
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgPos %~ const Nothing
|
||||
@@ -121,7 +121,7 @@ targetCursorUpdate w t
|
||||
|
||||
targetRBPressUpdate :: World -> Targeting -> Targeting
|
||||
targetRBPressUpdate w t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w = t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) = t
|
||||
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgPos %~ const Nothing
|
||||
@@ -140,7 +140,7 @@ targetLaserUpdate _ cr w t
|
||||
(mp, _) = reflectLaserAlong 0.2 sp ep w
|
||||
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos w -.- sp)
|
||||
addLaserPic = lasers .:~ LaserStart
|
||||
addLaserPic = cWorld . lasers .:~ LaserStart
|
||||
{ _lpPhaseV = 1
|
||||
, _lpDir = _crDir cr
|
||||
, _lpPos = sp
|
||||
|
||||
@@ -99,12 +99,12 @@ explodeRemoteRocket
|
||||
-> World
|
||||
-> World
|
||||
explodeRemoteRocket itid pjid w = w
|
||||
& projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||
& projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||
& cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& itPoint . itUse . rUse .~ HeldDoNothing
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
where
|
||||
itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||
thepj = _projectiles w IM.! pjid
|
||||
itPoint = pointToItem $ _itemPositions (_cWorld w) IM.! itid
|
||||
thepj = _projectiles (_cWorld w) IM.! pjid
|
||||
|
||||
|
||||
|
||||
@@ -12,17 +12,17 @@ import qualified IntMapHelp as IM
|
||||
import Control.Lens
|
||||
|
||||
setRemoteBombScope :: Int -> Prop -> World -> World
|
||||
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
|
||||
setRemoteBombScope itid pj w' = case _itemPositions (_cWorld w') IM.! itid of
|
||||
InInv cid invid
|
||||
-> w' & creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (_prPos pj -.- _crPos (_creatures w' IM.! cid))
|
||||
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
|
||||
-> w' & cWorld . creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (_prPos pj -.- _crPos (_creatures (_cWorld w') IM.! cid))
|
||||
& cWorld . creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
|
||||
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
|
||||
_ -> w'
|
||||
|
||||
setRemoteScope :: Int -> Point2 -> World -> World
|
||||
setRemoteScope itid pos w' = case w' ^? itemPositions . ix itid of
|
||||
setRemoteScope itid pos w' = case w' ^? cWorld . itemPositions . ix itid of
|
||||
Just (InInv cid' invid )
|
||||
-> w' & creatures . ix cid' . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid'))
|
||||
-> w' & cWorld . creatures . ix cid' . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures (_cWorld w') IM.! cid'))
|
||||
_ -> w'
|
||||
|
||||
@@ -6,7 +6,7 @@ import Geometry.Vector
|
||||
|
||||
import Control.Lens
|
||||
decTimMvVel :: Proj -> World -> World
|
||||
decTimMvVel pj = projectiles . ix pjid %~
|
||||
decTimMvVel pj = cWorld . projectiles . ix pjid %~
|
||||
( (prjTimer -~ 1)
|
||||
. (prjPos %~ (+.+ vel) )
|
||||
. (prjAcc %~ rotateV rot )
|
||||
|
||||
@@ -24,9 +24,9 @@ spawnCrNextTo
|
||||
-> Creature -- ^ existing creature that will be spawned next to
|
||||
-> World
|
||||
-> World
|
||||
spawnCrNextTo cr sCr w = w & creatures %~ IM.insert k newCr
|
||||
spawnCrNextTo cr sCr w = w & cWorld . creatures %~ IM.insert k newCr
|
||||
where
|
||||
k = IM.newKey $ _creatures w
|
||||
k = IM.newKey $ _creatures (_cWorld w)
|
||||
newCr = cr
|
||||
& crID .~ k
|
||||
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
||||
|
||||
@@ -95,7 +95,7 @@ type ChainEffect
|
||||
-> World
|
||||
|
||||
lockInvFor :: Int -> ChainEffect
|
||||
lockInvFor i f it cr = f it cr . (delayedEvents .:~ (i, UnlockInv (_crID cr)))
|
||||
lockInvFor i f it cr = f it cr . (cWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
|
||||
. lockInv (_crID cr)
|
||||
|
||||
trigDoAlso'
|
||||
@@ -139,7 +139,7 @@ withThickSmokeI eff item cr w = eff item cr
|
||||
ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff itm cr w
|
||||
| _laLoaded ic <= 0 || not (_laPrimed ic) = w
|
||||
| otherwise = eff itm cr $ w & creatures . ix (_crID cr) %~ crCancelReloading
|
||||
| otherwise = eff itm cr $ w & cWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
where
|
||||
ic = _itConsumption itm
|
||||
|
||||
@@ -149,7 +149,7 @@ ammoHammerCheck :: ChainEffect
|
||||
ammoHammerCheck eff it cr w
|
||||
| _laLoaded ic <= 0 || not (_laPrimed ic) = w -- fromMaybe w (startReloadingWeapon cr w)
|
||||
| otherwise = case it ^? itUse . useHammer of
|
||||
Just HammerUp -> eff it cr $ w & creatures . ix (_crID cr) %~ crCancelReloading
|
||||
Just HammerUp -> eff it cr $ w & cWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
_ -> w
|
||||
where
|
||||
ic = _itConsumption it
|
||||
@@ -184,7 +184,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
||||
startRate = _rateMaxMax . _useDelay $ _itUse item
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointItem = creatures . ix cid . crInv . ix itRef
|
||||
pointItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
currentRate = _rateMax (_useDelay (_itUse item))
|
||||
repeatFire = crWeaponReady cr && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = crWeaponReady cr && _rateTime (_useDelay (_itUse item)) == 0
|
||||
@@ -203,7 +203,7 @@ withWarmUp soundID f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
curWarmUp = _warmTime . _useDelay $ _itUse item
|
||||
maxWarmUp = _warmMax . _useDelay $ _itUse item
|
||||
withSoundItemChoiceStart
|
||||
@@ -259,12 +259,12 @@ withSoundForVol vol soundid playTime f item cr
|
||||
afterRecoil
|
||||
:: Float -- ^ Recoil amount
|
||||
-> ChainEffect
|
||||
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (creatures . ix cid) pushback
|
||||
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (cWorld . 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 (creatures . ix cid) pushback
|
||||
withRecoil eff it cr = eff it cr . over (cWorld . creatures . ix cid) pushback
|
||||
where
|
||||
cid = _crID cr
|
||||
recoilAmount = fromMaybe 0 $ it ^? itParams . recoil
|
||||
@@ -275,7 +275,7 @@ withSidePushI
|
||||
:: Float -- ^ Maximal possible side push amount
|
||||
-> ChainEffect
|
||||
withSidePushI maxSide eff item cr w = eff item (push cr) $ w
|
||||
& creatures . ix cid %~ push
|
||||
& cWorld . creatures . ix cid %~ push
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -287,7 +287,7 @@ Applied after the underlying effect. -}
|
||||
withSidePushAfterI
|
||||
:: Float -- ^ Maximal possible side push amount
|
||||
-> ChainEffect
|
||||
withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff item cr $ w
|
||||
withSidePushAfterI maxSide eff item cr w = over (cWorld . creatures . ix cid) push . eff item cr $ w
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -295,14 +295,14 @@ withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff
|
||||
(pushAmount, g) = randomR (-maxSide,maxSide) $ _randGen w
|
||||
useAllAmmo :: ChainEffect
|
||||
useAllAmmo eff item cr = eff item cr
|
||||
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded .~ 0)
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded .~ 0)
|
||||
useAmmoUpTo :: Int -> ChainEffect
|
||||
useAmmoUpTo amAmount eff item cr = eff item cr
|
||||
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded
|
||||
%~ (max 0 . subtract amAmount))
|
||||
useAmmoAmount :: Int -> ChainEffect
|
||||
useAmmoAmount amAmount eff item cr = eff item cr
|
||||
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded -~ amAmount)
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded -~ amAmount)
|
||||
{- |
|
||||
Applies a world effect after an item use cooldown check. -}
|
||||
useTimeCheck :: ChainEffect
|
||||
@@ -311,7 +311,7 @@ useTimeCheck f item cr w = case item ^? itUse . useDelay . rateTime of
|
||||
_ -> w
|
||||
where
|
||||
cid = _crID cr
|
||||
setUseTime = creatures . ix cid . crInv . ix (crSel cr) . itUse . useDelay . rateTime +~ userate
|
||||
setUseTime = cWorld . creatures . ix cid . crInv . ix (crSel cr) . itUse . useDelay . rateTime +~ userate
|
||||
userate = fromMaybe 0 $ item ^? itUse . useDelay . rateMax
|
||||
{- | Applies a world effect after a hammer position check. -}
|
||||
hammerCheckI :: ChainEffect
|
||||
@@ -332,7 +332,7 @@ ammoUseCheck f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = crSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = crWeaponReady cr
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _laLoaded (_itConsumption item) > 0
|
||||
@@ -364,7 +364,7 @@ shootL f item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
invid = _ipInvID $ _itPos item
|
||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||
pointerToItem = cWorld . creatures . ix cid . crInv . ix invid
|
||||
fireCondition = _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _arLoaded (_itConsumption item) > 0
|
||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
@@ -373,20 +373,20 @@ withItem g f it = g it f it
|
||||
|
||||
-- not ideal
|
||||
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
||||
withItemUpdate' up f it cr = f (up it) cr . (creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
withItemUpdate' up f it cr = f (up it) cr . (cWorld . 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 . (creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
withItemUpdate up g f it cr = g it f it cr . (cWorld . 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 tempLightSources (theTLS :)
|
||||
. over (cWorld . tempLightSources) (theTLS :)
|
||||
where
|
||||
theTLS = tlsTimeRadColPos time rad col (V3 x y 10)
|
||||
V2 x y = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||
|
||||
modClock :: Int -> ChainEffect -> ChainEffect
|
||||
modClock n chainEff eff it cr w
|
||||
| _worldClock w `mod` n == 0 = chainEff eff it cr w
|
||||
| _worldClock (_cWorld w) `mod` n == 0 = chainEff eff it cr w
|
||||
| otherwise = eff it cr w
|
||||
|
||||
withMuzFlareI :: ChainEffect
|
||||
@@ -491,9 +491,9 @@ torqueBefore
|
||||
torqueBefore torque feff item cr w
|
||||
| cid == 0 = feff item (cr & crDir +~ rot) $ w
|
||||
& randGen .~ g
|
||||
& creatures . ix cid . crDir +~ rot
|
||||
& cameraRot +~ rot
|
||||
| otherwise = feff item cr $ set randGen g $ over (creatures . ix cid . crDir) (+rot) w
|
||||
& cWorld . creatures . ix cid . crDir +~ rot
|
||||
& cWorld . cameraRot +~ rot
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . creatures . ix cid . crDir) (+rot) w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (-torque,torque) $ _randGen w
|
||||
@@ -506,9 +506,9 @@ torqueBeforeAtLeast
|
||||
torqueBeforeAtLeast minTorque exTorque feff item cr w
|
||||
| cid == 0 = feff item (cr & crDir +~ rot') $ w
|
||||
& randGen .~ g
|
||||
& creatures . ix cid . crDir +~ rot'
|
||||
& cameraRot +~ rot'
|
||||
| otherwise = feff item cr $ set randGen g $ over (creatures . ix cid . crDir) (+rot') w
|
||||
& cWorld . creatures . ix cid . crDir +~ rot'
|
||||
& cWorld . cameraRot +~ rot'
|
||||
| otherwise = feff item cr $ set randGen g $ over (cWorld . creatures . ix cid . crDir) (+rot') w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (-exTorque,exTorque) $ _randGen w
|
||||
@@ -518,8 +518,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 cameraRot (+rot) $ feff item cr w
|
||||
| otherwise = set randGen g $ over (creatures . ix cid . crDir) (+rot) $ feff item cr w
|
||||
| cid == 0 = set randGen g $ over (cWorld . cameraRot) (+rot) $ feff item cr w
|
||||
| otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+rot) $ feff item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (-torque,torque) $ _randGen w
|
||||
@@ -547,12 +547,12 @@ sideEffectOnFrame :: Int
|
||||
-> (Item -> Creature -> WdWd)
|
||||
-> ChainEffect
|
||||
sideEffectOnFrame i sf f it cr w = f it cr w
|
||||
& delayedEvents .:~ (i, sf it cr)
|
||||
& cWorld . delayedEvents .:~ (i, sf it cr)
|
||||
|
||||
torqueSideEffect :: Float -> Item -> Creature -> World -> World
|
||||
torqueSideEffect torque _ cr w
|
||||
| cid == 0 = set randGen g $ over cameraRot (+rot) w
|
||||
| otherwise = set randGen g $ over (creatures . ix cid . crDir) (+rot) w
|
||||
| cid == 0 = set randGen g $ over (cWorld . cameraRot) (+rot) w
|
||||
| otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+rot) w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (-torque,torque) $ _randGen w
|
||||
|
||||
@@ -90,11 +90,11 @@ useForceFieldGun itm cr w = fromMaybe w $ do
|
||||
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
|
||||
wlline = (a,b)
|
||||
return $ w
|
||||
& walls %~ IM.insertWith (\_ x -> x) i forceField {_wlID = i}
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itParams . paramMID ?~ i
|
||||
& cWorld . walls %~ IM.insertWith (\_ x -> x) i forceField {_wlID = i}
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itPos itm)) . itParams . paramMID ?~ i
|
||||
& moveWallIDUnsafe i wlline
|
||||
where
|
||||
i = fromMaybe (IM.newKey (_walls w)) $ itm ^? itParams . paramMID . _Just
|
||||
i = fromMaybe (IM.newKey (_walls (_cWorld w))) $ itm ^? itParams . paramMID . _Just
|
||||
|
||||
-- grapGun = defaultGun
|
||||
-- { _itName = "grapGun"
|
||||
|
||||
Reference in New Issue
Block a user